get notepad on windows to front via tcp-server

Tim Golden tim.golden at
Tue Mar 2 10:00:06 CET 2004

>Is there some way to make notepad to become the front window when it
>is started from within a tcp-server, using something like
>os.system("notepad") or
>os.system("start /w notepad")
>Using these methods from a python shell works as expected, but using a
>tcp-client/server construct gives me notepad in the rear.

There is -- as far as I know -- no switch you can pass to notepad
 (or any other application I know about) which will force it to
 become the foreground window.

If you can get the window handle (depends a bit on how you launch
 the app and/or how much you can guarantee about its title), you
 could use the technique outlined here:

The essential bits are the BringWindowToTop and SetForegroundWindow
 functions which are available via the win32gui module of pywin32.
 But you do have to find the window handle first. SetForegroundWindow
 has a number of restrictions which explain the rest of the code
 in the example. See here for explanations:


This e-mail has been scanned for all viruses by Star Internet. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:

More information about the Python-list mailing list