[Tutor] any win32com experts out there?

Alan Gauld alan.gauld at btinternet.com
Sat Nov 18 02:40:09 CET 2006


I'm no expert but I get the same response when I tried it.

I googled a bit and found this long chain of useful looking stuff:

http://www.velocityreviews.com/forums/t345123-how-to-receive-events-eg-user-mouse-clicks-from-ie.html

One possibility mentioned at the end is:

''''
Adding win32gui.PumpWaitingMessages() to the wait loop
seems to allow both event hooks to run without blocking each other.
''''
But it discusses IE not iTunes so it may not be relevant...

Alan G.

"Orri Ganel" <singingxduck at gmail.com> wrote in message 
news:455E3D44.8030000 at gmail.com...
> Hello again.  As I've mentioned in the last couple of emails, I'm 
> having
> trouble registering iTunes for events, and I don't know if it's a 
> bug
> with iTunes or with win32com, or if there's something I'm doing 
> wrong.
> So, if any win32com gurus out there know why the following doesn't 
> work
> and how to change it so it does work, a tip would be much 
> appreciated.
>
> >>> import win32com.client
> >>> class iTunesEvents:
>    def __init__(self):
>        print "starting iTunesEvents"
>    def OnPlayerPlayEvent(self, track):
>        print "playing"
>    def OnPlayerStopEvent(self, track):
>        print "stopped"
>    def OnDatabaseChangedEvent(self, deleted, changed):
>        print "database changed"
>    def OnPlayerPlayingTrackChangedEvent(self, track):
>        print "info on current track changed"
>    def OnCOMCallsDisabledEvent(self, reason):
>        print "com calls disabled"
>    def OnCOMCallsEnabledEvent(self):
>        print "com calls enabled"
>    def OnQuittingEvent(self):
>        print "quitting"
>    def OnAboutToPromptUserToQuitEvent(self):
>        print "prompting user to quit"
>    def OnSoundVolumeChangedEvent(self, newvolume):
>        print "volume changed"
>
>
> >>> iTunes = 
> >>> win32com.client.gencache.EnsureDispatch("iTunes.Application")
> >>> iTEvents = win32com.client.WithEvents(iTunes, iTunesEvents)
> starting iTunesEvents
> >>> iTunes.Play()
> >>> iTunes.Pause()
> >>> iTunes.Play()
> >>> iTunes.Pause()
>
> iTunes did, in fact, play and pause as expected, but as can be seen, 
> no
> events were caught.
>
> Stumped,
> Orri
>
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
> 




More information about the Tutor mailing list