[python-win32] USB Insertion Extrinsic Event exists?

Tim Golden mail at timgolden.me.uk
Fri Feb 12 17:23:53 CET 2010


On 12/02/2010 15:52, Chris Jesse wrote:
> Hi TJG,
>
> Thanks for your very helpful reply and code snippet.
> I'm happy that there seems to be a way to do this in windows.
> The application is multi-threaded with the MainThread being a wxPython
> MainLoop which monitors for events such as Shutdown (QUERY_END_SESSION) etc.
> It has to be the MainThread in order to receive the events.


> Is it possible that the Win32_VolumeChangeEvent or Win32_DeviceChangeEvent
> events can be detected a seperate thread? The example
> "detect-device-insertion" uses an infinate loop win32gui.PumpMessages()
> for WM_DEVICECHANGE. We can't use this as our MainThread as it's
> already in the wx MainLoop().


It's certainly possible to receive WMI events in a thread. There's
a fairly relevant example here:

http://timgolden.me.uk/python/wmi/cookbook.html#monitor-multiple-machines-for-power-events

It should be possible to adapt the PumpMessages loop into a wxPython
main loop but I'm not a wxPython person so you'd have to look around or ask
over there on the wx mailing list.

TJG


More information about the python-win32 mailing list