win32gui question - is my window the foreground window?

Linus Chang Linus_Chang1 at bigpond.com
Sun Jun 11 07:38:16 EDT 2000


Hi all,

I'd like to detect if the window of my wxPython application is currently 
the foreground window.

The way I'm thinking of doing this is to use the GetForegroundWindow 
function to grab the handle of the current foreground window and compare 
it with my own handle (got by using the GetActiveWindow function)

(eg. http://msdn.microsoft.com/library/psdk/winui/windows_08tv.htm)

However, win32gui only gives me SetForegroundWindow, not Get...

Is there a better way of doing this? A wxPython method would be 
preferred but failing that a win32 specific way would be still be 
appreciated :-)

Assuming there's no better way of doing this, how would I go about 
calling the GetForegroundWindow and GetActiveWindow functions? Do I have 
to write c extensions for python?

Thanks in advance,

Linus Chang






More information about the Python-list mailing list