Jump to content

Multiple Process Detection Question


Sorn
 Share

Recommended Posts

I've been through the manual and read up on ProcessList ( ["name"] ) function but that only does part of what I'm after what I'm looking to do is grab all instances of the process running and then winactivate each one individually (ie..)

Find all copies of Notepad.exe running and activate one at a time. I want to keep each PID in a variable and be able to activate each one whenever is needed but Winactivate only handles processname and if each copy has the same name it doesn't really help me. Is there a better way to activate each window via the PID?

Thanks

~Sorn

Link to comment
Share on other sites

  • Moderators

I've been through the manual and read up on ProcessList ( ["name"] ) function but that only does part of what I'm after what I'm looking to do is grab all instances of the process running and then winactivate each one individually (ie..)

Find all copies of Notepad.exe running and activate one at a time. I want to keep each PID in a variable and be able to activate each one whenever is needed but Winactivate only handles processname and if each copy has the same name it doesn't really help me. Is there a better way to activate each window via the PID?

Thanks

~Sorn

You'll use ProcessList + WinList + WinGetProcess (to match the window to the PID returned from the processlist array). Then you'll use the Handle to the window (which is returned in [n][1] of the WinList array) to activate each individual window.

Handles are unique to open windows, so it won't matter if it has the same title.

An example you may be able to pull from:

#include <array.au3>
Local $aPL = ProcessList("Notepad.exe")
Local $aWL = WinList()
;_ArrayDisplay($aPL);un-comment _ArrayDisplay to see process list array
;_ArrayDisplay($aWL);un-comment _ArrayDisplay to see process list array

For $i = 1 To UBound($aPL) - 1
    For $p = 1 To UBound($aWL) - 1
        If WinGetProcess($aWL[$p][1]) = $aPL[$i][1] Then
            MsgBox(64, "Info", "Process Name: " & $aPL[$i][0] & @CRLF & _
                "Process ID: " & $aPL[$i][1] & @CRLF & _
                "Window(s) Name: " & $aWL[$p][0] & @CRLF & _
                "Window(s) Handle: " & $aWL[$p][1])
                
        EndIf
    Next
Next

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.

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...