Jump to content

Recommended Posts

Posted

Hello community, i'm try to make a script for get the handle-pid of a process. I don't have problem if i have only one process, but if are two or more with the same name not work:

Local $aPID1, $aPID2

Run("notepad.exe")
Sleep(100)
Run("notepad.exe")
Sleep(100)

$list = ProcessList("notepad.exe")
For $i = 1 To $list[0][0]
    ConsoleWrite("NAME: " & $list[$i][0] & " - PID: " & $list[$i][1] & @CRLF)
    $aPID1 = $list[$i][1]
Next

If $aPID1 <> "" Then
    $Winlist = WinList()
    For $i = 1 To $Winlist[0][0]
        If $Winlist[$i][0] <> "" Then
            $aPID2 = WinGetProcess($Winlist[$i][1])
            If $aPID1 = $aPID2 Then
                ConsoleWrite("HANDLE: " & $Winlist[$i][1] & " - PID: " & $aPID2 & @CRLF)
                ExitLoop
            EndIf
        EndIf
    Next
EndIf

Output:

NAME: notepad.exe - PID: 1320
NAME: notepad.exe - PID: 2644
HANDLE: 0x00570202 - PID: 2644

The problem is i need to store the $aPID1 in an array and then compare it with $aPID2, i think

Suggestion to how to realize that? Thank you :D

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...