Re: Launch an application and continue the script's execution

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Tim Golden

    Re: Launch an application and continue the script's execution

    Gabriel Genellina wrote:
    Start the application in a separate console (using `start "" bat_file`
    might be the easiest way) and then, within your Python script, wait
    until the new process is ready. The wmi module by Tim Golden can help
    <http://tgolden.sc.sabr en.com/python/wmi.html>
    e.g. wait until Microsoft Word opens:
    >
    import wmi
    c = wmi.WMI()
    while not len(c.Win32_Pro cess(name="winw ord.exe")):
    sleep(500)
    Just for information's sake, you can do this
    a little more neatly in WMI:

    <code>
    import wmi

    c = wmi.WMI ()
    word_watcher = c.Win32_Process .watch_for (name="winword. exe")
    winword = word_watcher ()

    </code>

    Actually, now I look it's not that much neater; it basically
    pushes the polling into WMI itself. Still, it is at least an
    alternative :)

    TJG
Working...