/\/\1|<3 0 Posted January 29, 2005 (edited) i coded these functions because i was very bored :"> maybe its usefull for a few of you the first function returns an array conating the number of processes found (array[0]) and the others contain the Ids of the processes by giving the name of the process the second function returns the name of a process by giving its Id expandcollapse popupFunc ProcessGetId($Process) If IsString($Process) = 0 Then SetError(2) ElseIf ProcessExists($Process) = 0 Then SetError(1) Else Local $PList = ProcessList($Process) Local $i Local $PId[$PList[0][0] + 1] $PId[0] = $PList[0][0] For $i = 1 To $PList[0][0] $PId[$i] = $PList[$i][1] Next Return $PId EndIf EndFunc Func ProcessGetName($PId) If IsNumber($PId) = 0 Then SetError(2) ElseIf $PId > 9999 Then SetError(1) Else Local $PList = ProcessList() Local $i = 1 Local $ProcessName = "" While $i <= $PList[0][0] And $ProcessName = "" If $PList[$i][1] = $PId Then $ProcessName = $PList[$i][0] Else $i = $i + 1 EndIf WEnd Return $ProcessName EndIf EndFunc example: $PId = ProcessGetId("notepad.exe"); Gets the PId MsgBox(0, "Processes: " & $PId[0], "First process Id: " & $PId[1]); shows the Id MsgBox(0, "Name Check", "Given name was: " & ProcessGetName($PId[1])); shows the name for the following function you need the Id of a Process. you can get it with my ProcessGetId function. you also need my ProcessGetName function: Func ProcessGetWindow($PId) If IsNumber($PId) = 0 Or ProcessExists(ProcessGetName($PId)) = 0 Then SetError(1) Else Local $WinList = WinList() Local $i = 1 Local $WindowTitle = "" While $i <= $WinList[0][0] And $WindowTitle = "" If WinGetProcess($WinList[$i][0], "") = $PId Then $WindowTitle = $WinList[$i][0] Else $i = $i + 1 EndIf WEnd Return $WindowTitle EndIf EndFunc i hope you like it Mike Edited February 6, 2005 by /\/\1|<3 Share this post Link to post Share on other sites
Valik 478 Posted January 29, 2005 I see a sanity check where you look to see if a PID is less than 1000... A PID can be less than 1000. There are 6 processes on my system with a PID less than 1000, 5 of which are running under my account, the other under SYSTEM. There are two more if you count System and System Idle Process. Share this post Link to post Share on other sites
/\/\1|<3 0 Posted January 29, 2005 thanks + edited Mike Share this post Link to post Share on other sites
/\/\1|<3 0 Posted February 6, 2005 - added ProcessGetWindow function if you use it like this: $PId = ProcessGetId("Diablo II.exe") For $i = 1 To $PId[0] MsgBox(0, "window matching with " & $PId[$i], ProcessGetWindow($PId[$i])) Next then it shows you all existing diablo 2 windows enjoy Mike Share this post Link to post Share on other sites
Insolence 2 Posted February 6, 2005 Awesome "I thoroughly disapprove of duels. If a man should challenge me, I would take him kindly and forgivingly by the hand and lead him to a quiet place and kill him." - Mark TwainPatient: "It hurts when I do $var_"Doctor: "Don't do $var_" - Lar. Share this post Link to post Share on other sites
bshoenhair 0 Posted February 7, 2005 @/\/\1|<3 Nice job. Share this post Link to post Share on other sites