I am trying to create a loop and send the same key to multiple game windows. The idea is to press the "loot" key on several game clients.
This is my first time trying to code with AHK.
I managed to send the same key over and over again on a single client using this code :
Code: Select all
#SingleInstance force
#Persistent
#NoEnv
SetTimer, lootStuff, 250
return
lootStuff:
IfWinActive ahk_class ArenaNet_Dx_Window_Class
{
SendInput {F12}
}
return
The core issue is that all the clients share the same name "Guild Wars 2" so we need to get the process IDs.
Here is the terribly bad code I've come up with :
Code: Select all
#Persistent
WinGet, IDs, List , Guild Wars 2 ; get a list of all windows which match this windowTitle
Loop, %ids%
{
_hWin := ids%A_Index%
GroupAdd, WinGroup, ahk_id %_hWin%
}
return
1::
SetTimer, lootStuff, 250
lootStuff:
SendInput {f}, ahk_group WinGroup
return
Thanks,
Guillaume