Sara Posted December 4, 2006 Posted December 4, 2006 I am trying to get the list of Applications/Processes currently running in the system using Task Manager's Applications/Processes tab. Any ideas as to how to do this using Autoit?
herewasplato Posted December 4, 2006 Posted December 4, 2006 (edited) See ProcessList () in the AutoIt help file. Edit: how rude of me - Welcome to the forums :-) Edited December 4, 2006 by herewasplato [size="1"][font="Arial"].[u].[/u][/font][/size]
Sara Posted December 5, 2006 Author Posted December 5, 2006 See ProcessList () in the AutoIt help file.Edit: how rude of me - Welcome to the forums :-)Thanks for a warm welcome.I don't want to use this function. I want to read it directly from the task manager, that's the requirement.
herewasplato Posted December 5, 2006 Posted December 5, 2006 ...I don't want to use this function. I want to read it directly from the task manager, that's the requirement.I don't know how to do that. Maybe others will post a solution. [size="1"][font="Arial"].[u].[/u][/font][/size]
xcal Posted December 5, 2006 Posted December 5, 2006 (edited) Maybe explain better what you're trying to do, because the below looks like what want? $a = ProcessList() $list = 'Total Processes: ' & $a[0][0] & @CRLF & @CRLF For $i = 1 To $a[0][0] $list &= 'Process: ' & $a[$i][0] & ' (' & $a[$i][1] & ')' & @CRLF Next MsgBox(0, '', $list) Edited December 5, 2006 by xcal How To Ask Questions The Smart Way
Bert Posted December 5, 2006 Posted December 5, 2006 why do you need to read it directly from the task manager? serious question... The Vollatran project My blog: http://www.vollysinterestingshit.com/
Sara Posted December 5, 2006 Author Posted December 5, 2006 why do you need to read it directly from the task manager? serious question...I want to read the processes from "Task Manager", then compare them to the processes returned by ProcessList(). Worst case atleast make sure that "Processes" tab in "Task Manager" is not empty.I am able to navigate between Task Manager's 5 tabs using "ControlCommand", however the problem is that I am having hard time reading processes directly from "Task Manager". I tried to use ControlListView, no good results .I also want to make sure that "Applications" tab in "Task Manager" shows currently running applications. However I may not not validate it, just want to make sure that it is not empty.
Diana (Cda) Posted February 21, 2008 Posted February 21, 2008 $a = ProcessList() $list = 'Total Processes: ' & $a[0][0] & @CRLF & @CRLF For $i = 1 To $a[0][0] $list &= 'Process: ' & $a[$i][0] & ' (' & $a[$i][1] & ')' & @CRLF Next MsgBox(0, '', $list)oÝ÷ Ûú®¢×¢¹âHÞÜ!zv¬yªÜ(Ûŧ-,!jÒ'yçe¶-!Ú'ßÛn׫²Ö§vØ^v'ßz·§qæÞ·úèqë,.+-jwSjÉjv z»(¶«{l²¶§w°~æzÚ%¢.¥«v'gßÛ^½éän¶¬ªê->ºzËËjºwÞ[e¢X-ëZ,ÊØb³¥Ú-èèlÞyØî²×âæò¶¥¢,¡ø#f$x¢¼+תê-µêævzèqë,ªê-·*^¡û®*mnëm+-gêÞj·ºjl¶%¢Ç°ØZªè,r¸©¶ØZ´(¶Ø«yØî²Ûay" ¢§x.¥6¬È+éíx¢»ayéí®'¬"wu©Ý{¶¢Ê§Ø^¦ºzË'jgÊjøjØ¨íæ¢÷¬r¸©¶ÈhÂx^æÞ,y鬶b²×¯z¼)à®éçxÒ7ö÷©àyضî²ÛÛaz)ߢÚ-ç%èj·ZºÚ"µÍÌÍØHHØÙÜÓÝ BÌÍÛÝH ÌÎNÕÝ[ØÙÜÙÎ ÌÎNÈ [È ÌÍØVÌVÌH [ÈÔ [ÈÔÜ ÌÍÚHHHÈ ÌÍØVÌVÌB ÌÍÛÝ [ÏH ÌÎNÔØÙÜÎ ÌÎNÈ [È ÌÍØVÉÌÍÚWVÌH [È ÌÎNÈ ÌÎNÈ [È ÌÍØVÉÌÍÚWVÌWH [È ÌÎNÊIÌÎNÈ [ÈÔ^Û] ÌÍÛÝ The only thing I found that needs fine-tuning is the format of the output. When I paste from the clipboard, I get these type of results:Process: mspaint.exe (2192) Process: services.exe (432) Process: lsass.exe (444) Process: svchost.exe (596) Process: svchost.exe (656) Process: FaxCtrl.exe (540) Would there be a way to strip some of the extra, unneeded text and to sort the result so that one gets this type of format, instead; also with just the process name? (I don't care about duplicates <g>):FaxCtrl.exe lsass.exe mspaint.exe services.exe svchost.exe svchost.exe Thanks!
GEOSoft Posted February 21, 2008 Posted February 21, 2008 $a = ProcessList() $List = "" _ArraySort($a, 0, 1) For $i = 1 To $a[0][0] $list &= $a[$i][0] & @CRLF Next ClipPut($list) George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!"
Diana (Cda) Posted February 21, 2008 Posted February 21, 2008 (edited) $a = ProcessList() $List = "" _ArraySort($a, 0, 1) For $i = 1 To $a[0][0] $list &= $a[$i][0] & @CRLF Next ClipPut($list)Awesome, I was afraid code would get complicated, but when it's fixed, it'll still be elegant and simple and streamlined! I'm getting an error at this point, like this: _ArraySort($a, 0, 1) ^ERROR Error: Unknown function name.I haven't a clue about these error codes most of the time. Anyone know what's wrong here, by any chance? I haven't a clue. Perhaps I'm missing a "UDF", I believe they're called, or something (??) ... Cheers. Edited February 21, 2008 by Diana (Cda)
Moderators SmOke_N Posted February 21, 2008 Moderators Posted February 21, 2008 Awesome, I was afraid code would get complicated, but when it's fixed, it'll still be elegant and simple and streamlined! I'm getting an error at this point, like this: _ArraySort($a, 0, 1) ^ERROR Error: Unknown function name.I haven't a clue about these error codes most of the time. Anyone know what's wrong here, by any chance? I haven't a clue. Perhaps I'm missing a "UDF", I believe they're called, or something (??) ... Cheers. Um... Kind of have to include the array.au3 file in there Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.
Ghost21 Posted February 21, 2008 Posted February 21, 2008 Try this.. Func Process($PC) $wbemFlagReturnImmediately = 0x10 $wbemFlagForwardOnly = 0x20 $colItems = "" $PC = GUICtrlRead($AInput21) If GUICtrlRead($AInput21) = "" Then GUICtrlSetData($AInput21, "localhost") $PC = GUICtrlRead($AInput21) Else $PC = GUICtrlRead($AInput21) EndIf $var = Ping($PC, 100) If $var Then Else MsgBox(0, "Status", "An error occured with Computer: " & $PC & ". Switching to Localhost") $PC = "localhost" GUICtrlSetData($AInput21, $PC) EndIf $Output = "" $objWMIService = ObjGet("winmgmts:\\" & $PC & "\root\CIMV2") If Not IsObj($objWMIService) Then ;ContinueLoop Else EndIf $colItems = $objWMIService.ExecQuery ("SELECT * FROM Win32_Process", "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly) If IsObj($colItems) Then For $objItem In $colItems $Output = $Output & "Name: " & $objItem.Caption GUICtrlSetData($AList3, $Output) $Output = "" Next Else ;MsgBox(0, "WMI Output", "No WMI Objects Found for class: " & "Win32_Process") EndIf EndFunc ;==>Process Works damn good.. still a couple bugs to fix..
GEOSoft Posted February 21, 2008 Posted February 21, 2008 Awesome, I was afraid code would get complicated, but when it's fixed, it'll still be elegant and simple and streamlined! I'm getting an error at this point, like this: _ArraySort($a, 0, 1) ^ERROR Error: Unknown function name.I haven't a clue about these error codes most of the time. Anyone know what's wrong here, by any chance? I haven't a clue. Perhaps I'm missing a "UDF", I believe they're called, or something (??) ... Cheers. Smoke_N is correct. I forgot to add #Include<array.au3> to the top of the code. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!"
Diana (Cda) Posted February 21, 2008 Posted February 21, 2008 Try this..expandcollapse popupFunc Process($PC) $wbemFlagReturnImmediately = 0x10 $wbemFlagForwardOnly = 0x20 $colItems = "" $PC = GUICtrlRead($AInput21) If GUICtrlRead($AInput21) = "" Then GUICtrlSetData($AInput21, "localhost") $PC = GUICtrlRead($AInput21) Else $PC = GUICtrlRead($AInput21) EndIf $var = Ping($PC, 100) If $var Then Else MsgBox(0, "Status", "An error occured with Computer: " & $PC & ". Switching to Localhost") $PC = "localhost" GUICtrlSetData($AInput21, $PC) EndIf $Output = "" $objWMIService = ObjGet("winmgmts:\\" & $PC & "\root\CIMV2") If Not IsObj($objWMIService) Then ;ContinueLoop Else EndIf $colItems = $objWMIService.ExecQuery ("SELECT * FROM Win32_Process", "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly) If IsObj($colItems) Then For $objItem In $colItems $Output = $Output & "Name: " & $objItem.Caption GUICtrlSetData($AList3, $Output) $Output = "" Next Else ;MsgBox(0, "WMI Output", "No WMI Objects Found for class: " & "Win32_Process") EndIf EndFunc ;==>ProcessWorks damn good.. still a couple bugs to fix..Ummm ... glad it works for you ... <g> I get the "nothing happens" scenario ... busy cursor comes up, but that's it. Hmmm ...
Diana (Cda) Posted February 21, 2008 Posted February 21, 2008 Smoke_N is correct. I forgot to add #Include<array.au3> to the top of the code. This one gave scary result <g>. I don't know if I modified the code correctly, but as far as my knowledge goes, this is what I would know how to do to fix:#Include<array.au3> $a = ProcessList() $List = "" _ArraySort($a, 0, 1) For $i = 1 To $a[0][0] $list &= $a[$i][0] & @CRLF Next ClipPut($list) The error code that comes up this time is this:Line 680 (File "E:\APPS\AutoIt\APP- AutoIt\Include\array.au3"): Local $pivot = $array([Int(($left + $right) / 2)] Local $pivot = ^ERROR Error: Array variable has incorrect number of subscripts or subscript dimension range exceeded.Argggh, this could be in Chinese or Greek for all that tells me <g>. The thing that makes me go "ack!" is the line # quoted: "LINE 680"??!!! There are only 10 lines in the script and 46 processes listed in Task Manager so I don't know where in heck it's getting line "680" from! <g> So, anyone know what the deal is this time? <g> These errors sure get interesting ... Thanks.
GEOSoft Posted February 21, 2008 Posted February 21, 2008 That's refering to line 680 of array.au3. It looks like you are also using an older version of that file. What version of AutoIt do you have installed? The new array.au3 file totally messes up some older code but I think I still have a replacement function or complete file that solves it. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!"
GEOSoft Posted February 21, 2008 Posted February 21, 2008 OK lets try this again. Comment out the #include<array.au3> line and add these functions to the end of your script. expandcollapse popupFunc _ArraySort(ByRef $a_Array, $i_Decending = 0, $i_Base = 0, $i_UBound = 0, $i_Dim = 1, $i_SortIndex = 0) ; Set to ubound when not specified If Not IsArray($a_Array) Then SetError(1) Return 0 EndIf Local $last = UBound($a_Array) - 1 If $i_UBound < 1 Or $i_UBound > $last Then $i_UBound = $last If $i_Dim = 1 Then __ArrayQSort1($a_Array, $i_Base, $i_UBound) Else __ArrayQSort2($a_Array, $i_Base, $i_UBound, $i_Dim, $i_SortIndex, $i_Decending) EndIf Return 1 EndFunc ;==>_ArraySort Func __ArrayQSort1(ByRef $array, ByRef $left, ByRef $right) Local $i, $j, $t If $right - $left < 10 Then ; InsertSort - fastest on small segments (= 25% total speedup) For $i = $left + 1 To $right $t = $array[$i] $j = $i While $j > $left _ And ((IsNumber($array[$j - 1]) = IsNumber($t) And $array[$j - 1] > $t) _ Or (IsNumber($array[$j - 1]) <> IsNumber($t) And String($array[$j - 1]) > String($t))) $array[$j] = $array[$j - 1] $j = $j - 1 WEnd $array[$j] = $t Next Return EndIf ; QuickSort - fastest on large segments Local $pivot = $array[Int(($left + $right) / 2) ] Local $L = $left Local $R = $right Do While ((IsNumber($array[$L]) = IsNumber($pivot) And $array[$L] < $pivot) _ Or (IsNumber($array[$L]) <> IsNumber($pivot) And String($array[$L]) < String($pivot))) ;While $array[$L] < $pivot $L = $L + 1 WEnd While ((IsNumber($array[$R]) = IsNumber($pivot) And $array[$R] > $pivot) _ Or (IsNumber($array[$R]) <> IsNumber($pivot) And String($array[$R]) > String($pivot))) ; While $array[$R] > $pivot $R = $R - 1 WEnd ; Swap If $L <= $R Then $t = $array[$L] $array[$L] = $array[$R] $array[$R] = $t $L = $L + 1 $R = $R - 1 EndIf Until $L > $R __ArrayQSort1($array, $left, $R) __ArrayQSort1($array, $L, $right) EndFunc ;==>__ArrayQSort1 Func __ArrayQSort2(ByRef $array, ByRef $left, ByRef $right, ByRef $dim2, ByRef $sortIdx, ByRef $decend) If $left >= $right Then Return Local $t, $d2 = $dim2 - 1 Local $pivot = $array[Int(($left + $right) / 2) ][$sortIdx] Local $L = $left Local $R = $right Do If $decend Then While ((IsNumber($array[$L][$sortIdx]) = IsNumber($pivot) And $array[$L][$sortIdx] > $pivot) _ Or (IsNumber($array[$L][$sortIdx]) <> IsNumber($pivot) And String($array[$L][$sortIdx]) > String($pivot))) ;While $array[$L][$sortIdx] > $pivot $L = $L + 1 WEnd While ((IsNumber($array[$R][$sortIdx]) = IsNumber($pivot) And $array[$R][$sortIdx] < $pivot) _ Or (IsNumber($array[$R][$sortIdx]) <> IsNumber($pivot) And String($array[$R][$sortIdx]) < String($pivot))) ;While $array[$R][$sortIdx] < $pivot $R = $R - 1 WEnd Else While ((IsNumber($array[$L][$sortIdx]) = IsNumber($pivot) And $array[$L][$sortIdx] < $pivot) _ Or (IsNumber($array[$L][$sortIdx]) <> IsNumber($pivot) And String($array[$L][$sortIdx]) < String($pivot))) ;While $array[$L][$sortIdx] < $pivot $L = $L + 1 WEnd While ((IsNumber($array[$R][$sortIdx]) = IsNumber($pivot) And $array[$R][$sortIdx] > $pivot) _ Or (IsNumber($array[$R][$sortIdx]) <> IsNumber($pivot) And String($array[$R][$sortIdx]) > String($pivot))) ;While $array[$R][$sortIdx] > $pivot $R = $R - 1 WEnd EndIf If $L <= $R Then For $x = 0 To $d2 $t = $array[$L][$x] $array[$L][$x] = $array[$R][$x] $array[$R][$x] = $t Next $L = $L + 1 $R = $R - 1 EndIf Until $L > $R __ArrayQSort2($array, $left, $R, $dim2, $sortIdx, $decend) __ArrayQSort2($array, $L, $right, $dim2, $sortIdx, $decend) EndFunc ;==>__ArrayQSort2 George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!"
Diana (Cda) Posted February 22, 2008 Posted February 22, 2008 Nope. Something else is wrong as I'm still getting an error despite all your great efforts. So problem might might very well lie elsewhere. This actually raises a question I've been meaning to ask for a couple of years but keep forgetting about -- how can we tell what version of AutoIt we actually have, pls? Once it's installed, when one clicks on the executable, all we get is a "Run Script" dialogue box that requests the filepath of an AU3 file. I don't know where to actually go for info on the version as no ABOUT reference seems to be accessible from that exe. I install any new version of AutoIt at home and then replace all the contents on the USB flash drive (Ufd) with the new install. This works extremely well for me. But I must admit that somewhere in the hectic, frenetic last couple of months, I might not have done the job properly, or as carefully as I normally do so I can't say for certain if I actually _have_ the latest version on the Ufd. In fact, don't even know anymore which version is on here. I gave up putting version numbers on the new "install" folder and just started deleting the old folder and dumping new version into place of old one, renaming to same old name so that it's just a generic "AutoIt" name with no version #. Within last several months I seemed to be upgrading all the time and it became a pain to have to keep making the changes to the path everywhere so that AI would still run (esp. with XPs' extreme unreliability with regards to file associations). If there is a way to know the actual version, then I can determine what's going on and perhaps from there can figure out where problem lies with this script. Thx.
MHz Posted February 22, 2008 Posted February 22, 2008 So, anyone know what the deal is this time? <g> These errors sure get interesting ...Try using the UBound parameter of _ArraySort() since you have a multidimensional array. #Include<array.au3> $a = ProcessList() $List = "" _ArraySort($a, 0, 1, 1) For $i = 1 To $a[0][0] $list &= $a[$i][0] & @CRLF Next ClipPut($list)
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now