[python-win32] fast test if (unknown) process is running ? Why not use Autoit ?
Tim Golden
mail at timgolden.me.uk
Fri Aug 6 13:44:07 CEST 2010
On 06/08/2010 12:27, Stef Mientki wrote:
> hello,
>
> I wonder if there's a fast way to test if a process is running.
>
> these are my experiences till so far:
>
> 1. win32pdh, not usefull, because it shows ths status of some ancient history
>
> 2. wmi, VERY SLOW: 1500 .. 2000 msec
> import wmi
> w = wmi.WMI()
> processes = w.instances('Win32_Process')
> instances = []
> for process in processes :
> if process.Name.lower() == name :
> return process.ProcessId
>
> 3. Autoit, very fast: 10..20 msec
> autoit = win32com.client.Dispatch ( "AutoItX3.Control" )
> print autoit.ProcessExists ( process )
>
> Are the better (faster) ways, without the use of AutoIt ?
>
> Now this raises another question (please forgive my ignorance):
> Why not use AutoIt always, instead of all the win32 libraries ?
> AFAIK, the advantages of AutoIt:
> - seems to be very fast
> - is very well documented
> - can be tested in a AutoIt friendly editor (Scite)
> AFAIK the disadvantages:
> - when distributing, you must add an extra file
Try psutil (which uses the toolhelp DLL):
http://code.google.com/p/psutil/
<code>
import psutil
for p in psutil.process_iter ():
if p.name == "blah":
print p
break
else:
print "Not found"
</code>
TJG
More information about the python-win32
mailing list