Jump to content

PID-Handle for multiple window


MyEarth
 Share

Recommended Posts

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

Link to comment
Share on other sites

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

Edited by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...