I would like to get the WM_DEVICECHANGED message which is sent to top
level windows when there is a device added or removed. I couldn't
find anything in the wiki or the group archives discussing this
although I do remember similar topics discussed several times.
What I am actually doing is a program that will detect when the
CD drive is ejected and then automatically hibernates my computer.
The reason I am doing that is because I am busy converting my
laserdiscs to DVD and it takes several hours for the program
to do the conversion to DVD/mpeg data and then burn the disc.
When the disc is burnt, it is ejected. Consequently I leave
this stuff running overnight, but want my machine powered down
when it is done.
I did start doing the program in C++ but it takes SO much longer
than in Python!
might be a better place to search for that kind of functionality.
···
On Tue, 31 Aug 2004 21:21:35 -0700, Roger Binns <rogerb@rogerbinns.com> wrote:
I would like to get the WM_DEVICECHANGED message which is sent to top
level windows when there is a device added or removed. I couldn't
find anything in the wiki or the group archives discussing this
although I do remember similar topics discussed several times.
I did start doing the program in C++ but it takes SO much longer
than in Python!
I would like to get the WM_DEVICECHANGED message which is sent to top
level windows when there is a device added or removed. I couldn't
find anything in the wiki or the group archives discussing this
although I do remember similar topics discussed several times.
What I am actually doing is a program that will detect when the
CD drive is ejected and then automatically hibernates my computer.
The reason I am doing that is because I am busy converting my
laserdiscs to DVD and it takes several hours for the program
to do the conversion to DVD/mpeg data and then burn the disc.
When the disc is burnt, it is ejected. Consequently I leave
this stuff running overnight, but want my machine powered down
when it is done.
I did start doing the program in C++ but it takes SO much longer
than in Python!
Roger
---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org
Errr, no. I want to do the gui in wxPython. I just need one
event form the underlying Windows event loop. I have already
written the code in win32all to deal with the message and
parse all the information out, as well as a module to hibernate
the machine.
Have you tried just setting a hibernate timeout in the power options?
I'm not sure whether windows takes into account CPU activity (as well
as user interaction) to determine what constitutes idle time, but it's
at least worth a try.
···
On Tue, 31 Aug 2004 21:21:35 -0700, Roger Binns <rogerb@rogerbinns.com> wrote:
What I am actually doing is a program that will detect when the
CD drive is ejected and then automatically hibernates my computer.
The reason I am doing that is because I am busy converting my
laserdiscs to DVD and it takes several hours for the program
to do the conversion to DVD/mpeg data and then burn the disc.
When the disc is burnt, it is ejected. Consequently I leave
this stuff running overnight, but want my machine powered down
when it is done.
use some kind of IPC and make the module that hibernates comunicate with your app.
The simplest thing I could think is... a file... the module that hibernates reads from a file to see if the operation has completed and if the operation is still not done the hiberntation module sleeps for a period of time after which... it checks again... The GUI app... simply writes the file when done and exits...
···
On Wed, 1 Sep 2004 02:17:32 -0700, Roger Binns <rogerb@rogerbinns.com> wrote:
Errr, no. I want to do the gui in wxPython. I just need one
event form the underlying Windows event loop. I have already
written the code in win32all to deal with the message and
parse all the information out, as well as a module to hibernate
the machine.
I would like to get the WM_DEVICECHANGED message which is sent to top
level windows when there is a device added or removed. I couldn't
find anything in the wiki or the group archives discussing this
although I do remember similar topics discussed several times.
I did some google-ing because I am also curious about this. These are the things that I found:
I would like to get the WM_DEVICECHANGED message which is sent to top
level windows when there is a device added or removed. I couldn't
find anything in the wiki or the group archives discussing this
although I do remember similar topics discussed several times.
I thought I had already made a wiki page for this but I also couldn't find it, so I wrote a new one.
Well, I wasn't able to find out how to override the specific message handlers. So I did this little workaround.
Basically, it creates one window using win32api (that is never shown), which just waits on the event message WM_DEVICECHANGED
And that window can have callbacks registered for other objects to inform whenever media has been inserted or removed.
I've tested it here, and it seems to work. I feel like it is a little bit of a hack because of the empty window. But it works quite well, so I don't mind too much.
Hopefully this can help you down the right path.
John
=:->
Excellent, thanks. Now, how would one watch for underlying GTK
WM events and Mac events?
What are you interested in in particular? Windows is somewhat
different because *everything* is funnelled through the message
queues (and hence WndProc) inlcuding GUI stuff, but also things
like system power events, device notification, even async
networking.
It does have Python APIs but I couldn't find documentation for
them. I would think the easiest way to integrate them into
a wxPython program would be to run in a seperate thread and
use wx.PostMessage to notify the main gui thread of interesting
stuff.
I actually had already done all the win32 api stuff including
the structure decoding etc. I then started doing the gui
in C and it was too painful. I did more of it in win32all,
but really wanted wxPython since my time is valuable.
You've added ctypes as an extra dependency. I just did all
mine with struct.
def drive_from_mask (mask):
n_drive = 0
while 1:
if (mask & (2 ** n_drive)): return n_drive
else: n_drive += 1
That code is wrong in that it is a list of drives, not just
one. For example you could plug in a compact flash multi-reader
or a firewire drive with multiple partitions.
I used a dialog indirect which is a little less painful than this.
I also had to write a quick C module to wrap the SetSuspendState
function. I could probably have done it with ctypes etc, but
it only took me 20 seconds in Swig
Have you tried just setting a hibernate timeout in the power options?
I'm not sure whether windows takes into account CPU activity (as well
as user interaction) to determine what constitutes idle time, but it's
at least worth a try.
I would have to keep turning the timeouts on and off etc which would
be a pain. And doing it at the wrong time would be a really bad idea.
Consequently I am sticking to a particular drive being ejected.