How to receive events from a COM automation server

How in the name of ...

Heya people,

hope ur all doing just GREAT !!

It's been a while since I've shown any form of activity on the forums... been fair busy learning all sorts of things with DesktopX...

I also intend to post some objects based on concepts which I've discussed in the past within the next few weeks... so stick around... 'cause u may find some things u'll enjoy!!

Anyway... Please could somebody help me get this right...

How does one register a callback with a COM Server??

Eg:

Set fb2k = WScript.CreateObject("Foobar2000.Application.0.7")
Set playback = fb2k.Playback

ConnectObject playback, "playback_"

Sub playback_TrackChanged()
MsgBox "Track changed"
End Sub


This script works with the WSH but DesktopX obviously doesn't support ConnectObject...

BTW: I'm not using WScript.CreateObject in DesktopX... I am using only CreateObject... so that's not the problem

As stated by others... the ConnectObject statement returns a 'Type mismatched' error!!

Is it possible to use WithEvents in DesktopX??
If so... How?

PLEASE can somebody who knows how to do this show us how it's done... or let us know if it's even possible!!

Best wishes to everyone...
5,656 views 8 replies
Reply #1 Top
Well Guys ... what can I say ... I'm really disappointed by the fact that no one has replied to my post!!

It's been a month since I created this post and I still haven't heard a thing...

I would really appreciate it if someone from the DesktopX development team could clear this up already!!

Even if I can't achieve what I'd like to, I'd rather know than be left in the dark!!

So ultimately, what it comes down to it this:

We all know that it's possible for DesktopX to send messages to other applications through COM automation... but is it possible to receive messages from other applications??

For instance, when using the ITunes COM automation server, could you make a DesktopX object that changes state according to whether ITunes is playing or not??

I'm slowly losing my will to use DesktopX, as I find not being able to receive messages from my applications a HUGE limitation and enough to make me want to give up.

Please Please Please can someone tell me if there is a solution and if so ... What?

Thanks in advance,

Kind regards
Reply #2 Top

It's always a far better idea to title your thread allong the lines of its subject matter.....to attract appropriate responses...

If there's no reply within a day or so....just type the word 'bump' as a comment in the thread...as that will push it back onto the front page...where it may then attract respondents....

Reply #3 Top
Heya Jafo,

I suppose that could help ...

Anyway, I'll just have to wait and see ...
Hopefully somebody will be able to help!!

Thanks for the suggestion!!
Reply #5 Top
Didn't even see this. I've answered this one before. Remove the wscript part should do the trick just use this. Forgot where I picked this up but, here you.

Code: vbscript
  1. Set fb2k = CreateObject("Foobar2000.Application.0.7")
Reply #6 Top
Heya SirSmiley,

Thanks for the response...

I stated in the original post the I am not using WScript.CreateObject("Foobar2000.Application.0.7") but CreateObject("Foobar2000.Application.0.7") instead... however, that's not the problem...

I've managed to send messages to Foobar2000 using the following method:

Code: vbscript
  1. Set fb2k = WScript.CreateObject("Foobar2000.Application.0.7")
  2. Set playback = fb2k.Playback
  3. WScript.ConnectObject playback, "playback_"
  4. Sub playback_Started()
  5. WScript.Echo "Playback was started."
  6. End Sub


However, I've thus far been unable to receive any messages FROM the program...

eg: my progress bar, track time display and track title display don't update...

I know this can be achieved by using a timer to continuously check if Foobar2000 is playing or not, but I'm not to keen on the idea of using timers all the time as I personally find them somewhat of a resource hog...

Using a timer to update the progress bar and so on is one thing... but using a timer to keep on checking is Foobar2000 is playing is a bit much in my books!!

This is exactly why I want to figure out how to implement an event handler in DesktopX... also known as event sinking / catching events...

The following code works when used in a *.VBS file...

NOTE: The use of WScript.CreateObject("Foobar2000.Application.0.7") instead of CreateObject("Foobar2000.Application.0.7") is only because the script is running from a *.VBS file!!

Code: vbscript
  1. Set fb2k = WScript.CreateObject("Foobar2000.Application.0.7")
  2. Set playback = fb2k.Playback
  3. WScript.ConnectObject playback, "playback_"
  4. Sub playback_Started()
  5. WScript.Echo "Playback was started."
  6. End Sub


Please, please, please can someone show me how it's done or let me know if I'm taking shots in the dark!!

Thanks a stack!!
Reply #8 Top
Oops, sorry... I just noticed that the first code block in my previous post was incorrect, or at least the same as the second one...

The first code block was supposed to appear as follows:

Code: vbscript
  1. Set fb2k = CreateObject("Foobar2000.Application.0.7")
  2. Set playback = fb2k.Playback
  3. Function Object_OnLButtonUp(x, y, Dragged)
  4. playback.Start
  5. // OR
  6. playback.Pause
  7. // OR
  8. playback.Stop
  9. // AND SO FORTH
  10. End Function


And yes... I am using Foobar2000:Components 0.9/COM Automation Server at the link you posted...

Thanks!!