agassi0430
agassi0430

Reputation: 1195

WinGet multiple ahk_pid Process IDs within single AHK file

I'm creating an ahk script where I am trying to single to use the same logic across multiple Process IDs.

I have more than 5 of this window class / process name running, so I'm using the ahk_pid to specify the 2 that I want the script to run for.

I could open 2 separate files and specify a single ahk_pid in each, but is there a way to specify 2+ ahk_pids within a single script file?

When I try something similar to below, the script works for only the top pid.

pid = 1234
pid2 = 4321
WinGetTitle, clickTitle, ahk_pid %pid%
WinGetTitle, clickTitle, ahk_pid %pid2%
WinGetClass, clickClass, ahk_pid %pid%
WinGetClass, clickClass, ahk_pid %pid2%

Upvotes: 1

Views: 1181

Answers (1)

user10364927
user10364927

Reputation:

You have the same variable names for each WinGetTitle and WinGetClass. I tried using your code with two Notepad instances (and unique variables) and it ran successfully. With unique variable names, you can use your method with as many ahk_PID as you wish in one script.

f1::
pid = 1234
pid2 = 4321
WinGetTitle, clickTitle, ahk_pid %pid%
WinGetTitle, clickTitle2, ahk_pid %pid2%
WinGetClass, clickClass, ahk_pid %pid%
WinGetClass, clickClass2, ahk_pid %pid2%
ListVars
Return

Upvotes: 1

Related Questions