Radu Ciora wrote:
> Hi all,
>
> given this code:
>
>     while 1:
>         time.sleep(1)
>         
>         l_hwnd =  win32gui.GetForegroundWindow()
>         try:
>             msg = win32gui.GetMessage(l_hwnd, 0, 0)
>             print msg
>         except:
>               traceback.print_exc()
>
> can anyone tell me what's wrong with it, 'cos it doesn't print anything? 
> I'm trying to get into this tiny application message queue and print out the 
> messages that come in to it.

What messages do you expect to get?  Are you sending it messages from
somewhere else?  How are you doing that?

Are you actually creating any windows?  If not, then this will never
work.  GetForegroundWindow will return to you the handle of whatever
visible window happens to be frontmost.  If you're in a console, it's
the console window.  If you're in Pythonwin, it's the Pythonwin window. 
In either case, that window does not belong to your thread, so you will
never see any messages destined for that window.  Because you supplied a
window handle to GetMessage, it will only pull the messages for that
window handle.

If you want to get ALL messages sent to your thread, do
win32gui.GetMessage( 0, 0, 0 ), but again that begs the question of what
messages you are sending?

-- 
Tim Roberts, [EMAIL PROTECTED]
Providenza & Boekelheide, Inc.

_______________________________________________
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32

Reply via email to