[Tutor] any win32com experts out there?

Orri Ganel singingxduck at gmail.com
Fri Nov 17 23:52:52 CET 2006


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




More information about the Tutor mailing list