strComputer := "." objWMIService := ComObjGet("winmgmts:\\" . strComputer . "\root\cimv2") colProcesses := objWMIService.ExecQuery("Select * From Win32_Process")._NewEnum Gui, Add, ListView, x2 y0 w400 h500 vMyLV,Process Name|WorkingSetSize|Priority|ThreadCount GuiControl, -Redraw, MyLV While colProcesses[objProcess] LV_Add("",objProcess.Name , objProcess.WorkingSetSize , objProcess.Priority , objProcess.ThreadCount) GuiControl, +Redraw, MyLV LV_ModifyCol(1,160) Gui, Show, w400 h500, Process List Return GuiClose: ExitApp
List Running Processes [AHK_L]
Started by
shajul
, Dec 04 2010 07:37 AM
4 replies to this topic
Shorter code to list running processes than given in the documentation (http://www.autohotke...nds/Process.htm) using AHK_L
#1
-
Posted 04 December 2010 - 07:37 AM
Out of curiosity I did some speed tests.
The documented code on AHK Basic takes 0.042471 seconds to run.
The same code on AHK_L takes 0.021885 seconds to run.
And your code with changes to make it more like the above code takes 0.252985 seconds.
I was surprised to see that its slower.
Heres the code used to speed test it:
The documented code on AHK Basic takes 0.042471 seconds to run.
The same code on AHK_L takes 0.021885 seconds to run.
And your code with changes to make it more like the above code takes 0.252985 seconds.
I was surprised to see that its slower.
Heres the code used to speed test it:
While QPX(100) P() Msgbox % QPX() P() { strComputer := "." objWMIService := ComObjGet("winmgmts:\\" . strComputer . "\root\cimv2") colProcesses := objWMIService.ExecQuery("Select * From Win32_Process")._NewEnum While colProcesses[objProcess] List .= objProcess.Name "|" objProcess.WorkingSetSize "|" objProcess.Priority "|" objProcess.ThreadCount "`n" }QPX can be found here -> <!-- m -->http://www.autohotke...topic52083.html<!-- m -->
#2
-
Posted 04 December 2010 - 07:36 PM
aboutscript ⋰ apps ⋱ scripts
Request Video Tutorials Here or View Current Tutorials on YouTube
Any code ⇈ above ⇈ requires AutoHotkey_L to run
Request Video Tutorials Here or View Current Tutorials on YouTube
Any code ⇈ above ⇈ requires AutoHotkey_L to run
Generally more abstraction = slower. WMI probably just wraps those other APIs in some of its own logic; i.e. it does more work to the same effect.
Btw, after the next update you should be able to remove ._NewEnum and do:
Btw, after the next update you should be able to remove ._NewEnum and do:
for process in colProcessesAt the moment the for-loop calls ._NewEnum(), which doesn't work in this case.
#3
-
Posted 04 December 2010 - 11:11 PM
Well its good to see that _L can run the same script in the docs about twice as fast.
#4
-
Posted 04 December 2010 - 11:33 PM
aboutscript ⋰ apps ⋱ scripts
Request Video Tutorials Here or View Current Tutorials on YouTube
Any code ⇈ above ⇈ requires AutoHotkey_L to run
Request Video Tutorials Here or View Current Tutorials on YouTube
Any code ⇈ above ⇈ requires AutoHotkey_L to run
You could probably get the same speed-up in AutoHotkey Basic by resolving the dll function names using GetModuleHandle/GetProcAddress before-hand and calling by address instead of by name.
#5
-
Posted 04 December 2010 - 11:36 PM