get notepad on windows to front via tcp-server

Discussion in 'Python' started by Roger, Mar 1, 2004.

  1. Roger

    Roger Guest

    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.
     
    Roger, Mar 1, 2004
    #1
    1. Advertising

  2. Roger

    Larry Bates Guest

    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" <> wrote in message
    news:...
    > 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.
     
    Larry Bates, Mar 2, 2004
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. qqq111
    Replies:
    19
    Views:
    1,161
    Roedy Green
    Mar 1, 2006
  2. Chetan Gadgil
    Replies:
    1
    Views:
    330
    Roger
    Mar 4, 2004
  3. Tiger
    Replies:
    5
    Views:
    974
    Dave Thompson
    May 1, 2006
  4. Replies:
    1
    Views:
    142
    Brian Candler
    Mar 18, 2007
  5. Anukul Singhal
    Replies:
    4
    Views:
    244
    Anukul Singhal
    Mar 20, 2008
Loading...

Share This Page