get notepad on windows to front via tcp-server
Larry Bates
lbates at swamisoft.com
Tue Mar 2 11:33:36 EST 2004
You can use win32process to start the app which
gives you much more control over window size,
environment, etc.:
import win32process
STARTUPINFO=win32process.STARTUPINFO()
STARTUPINFO.dwX=0
STARTUPINFO.dwY=0
STARTUPINFO.dwXSize=800 # Horizontal window size
STARTUPINFO.dwYSize=600 # Vertical window size
commandLine=None
processAttributes=None
threadAttributes=None
bInheritHandles=0
dwCreationFlags=0
newEnvironment=None
currentDirectory="C:\\"
#
# Start the program
#
win32process.CreateProcess('C:\\WINDOWS\\system32\\notepad.exe',
commandLine,
processAttributes,
threadAttributes,
bInheritHandles,
dwCreationFlags,
newEnvironment,
currentDirectory,
STARTUPINFO)
-Larry
"Roger" <rlwm.erens at home.nl> wrote in message
news:5475062c.0403011527.22364bc4 at posting.google.com...
> I've got some MS-windows (XP only?) related questions; hopefully
> someone can give me some advise.
>
> 1)
> 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.
>
> I read an old thread from '98 about something very much related to
> this, but it used tk which I don't want to. Besides, the thread ended
> undecidedly.
>
> 2)
> From a python shell using
> os.system("write") or
> os.system("start /w write")
> gives me an exit code (zero) before I have closed the application
> wordpad. So os.system() is not waiting as I thought it should.
> Can this be explained?
>
> I have NOTEPAD.EXE in C:\windows and notepad.exe and write.exe in
> C:\windows\system32.
>
> Any help would be greatly appreciated.
More information about the Python-list
mailing list