catching WM_TIMER message
mail at timgolden.me.uk
Mon Sep 20 17:30:32 CEST 2010
On 20/09/2010 16:15, Greg Miller wrote:
> I'm trying to get the following code converted to Python.......and am
> if(msg.message == WM_TIMER)
> I think GetMessage is a canned C or C++ function, and I'm not sure how
> to catch a message from WM_TIMER. Anyone who could help me get this
> loop converted to Python I would really appreciate it!!!!
Goodness. You're going in at the deep end, slightly.
What you're seeing there is a typical part of the standard
Windows message loop which retrieves messages from the
message queue of a Window (or thread) and then dispatches
as your code does above. You *can* do this in Python, either
using core Python only and making use of the ctypes module,
or by employing the pywin32 packages which wrap the functions
There's a thread-based example here which uses ctypes:
It should be readily adaptable to a WM_TIMER situation.
Or you can see a (more complex) window-based example here which
uses the pywin32 package:
If all you needed was the simplest code to catch a WM_TIMER
message then the earlier example is probably a better fit.
If this is part of a wider setup involving windows and other
messages then you'll need (something like) the latter.
More information about the Python-list