> I hope you don't mind doing a little hand-holding, since I have zero > experience with Win32 and am therefore bumbling about. > > I looked at this: > > http://msdn2.microsoft.com/en-us/library/aa394362.aspx > > Which leads me to believe that the right way to do this is somewhere > along these lines:
Sadly, no. Nice try, though ;) What you're looking at is WMI. Very useful, and a kind of unified answer to all sorts of sys-adminy things. But it while it is COM/DCOM-based it doesn't operate like a normal COM class, which is what you're describing below (ish). In short you'd need to do something like this: <code> import win32com.client wmi = win32com.client.GetObject ("winmgmts:") power_watcher = wmi.ExecNotificationQuery ( "SELECT * FROM Win32_PowerManagementEvent" ) power_event = power_watcher.NextEvent () event_type = power_event.Properties_ ("EventType").Value if event_type == 4: # etc. elif event_type == 5: # etc. </code> That's pretty much untested but it's along the right lines. I'm the author of a helper WMI module which I know a number of people find useful in this area: http://timgolden.me.uk/python/wmi.html but in this case (a) I have embarrassingly little support for extrinsic events (which this is) although it's on my todo list and (b) it would be slightly overkill if all you need to do is what I've shown you above. That said, if you want to go the WMI module line, I'm quite happy to try to make things work there for what you need. As I said, I'd already decided I needed to do something in this area. Sorry this is a bit rushed; you've caught me on a really busy evening. TJG _______________________________________________ Python-win32 mailing list Python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32