get notepad on windows to front via tcp-server

R

Roger

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.
 
L

Larry Bates

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top