470,619 Members | 2,003 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,619 developers. It's quick & easy.

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.sabren.com/python/wmi.html>
e.g. wait until Microsoft Word opens:

import wmi
c = wmi.WMI()
while not len(c.Win32_Process(name="winword.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
Aug 27 '08 #1
0 1084

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

8 posts views Thread by Bob Bedford | last post: by
reply views Thread by Jeff Cooper | last post: by
7 posts views Thread by Christopher C | last post: by
1 post views Thread by pmclinn | last post: by
8 posts views Thread by Marcus | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.