[Tutor] win32gui, SetForegroundWindow() and setting focus

Tim Golden mail at timgolden.me.uk
Sun Mar 16 21:31:58 CET 2008

Scott Nelson wrote:
> Greetings all...
> I'm looking to use the win32api and win32gui modules to do a bit of
> Windows tinkering (win2k) and I've hit a snag.
> I'd like to programmatically set which window has the focus.  But
> win32gui.SetForegroundWindow(hwnd) seems to be what I'm looking for,
> but, it isn't working quite as I expect meaning I probably have a bad
> assumption.

Hi, Scott. I never can remember what the incantations
are to get this right, but if you trawl the various
Microsoft-oriented newsgroups (via Google, say) then
you see them littered with the corpses of people on
the same trail.

Assuming no-one on this list comes across with the
answer, check out the question on the wider web:
translating the answer back into Python is going to
be the easiest part ;)


More information about the Tutor mailing list