How to bind the script to a specific window?

Found this code as I need edited .
Essence - alternately press buttons 1 2 3 4 in a minimized window , in cycles .
Now I want to bind it , that it only worked in a certain window , I tried using ahk_class , but ran into a problem .
Window then I have two the same - and both have the same ahk class , how to make the Script work only in the second window ?

vk71::
Loop 
If isKeyPressed :=!isKeyPressed
{
{
 ControlSend,, {vk31 Down}, ahk_class SimWindow
 KeyWait, vk71
 Sleep 3150
 Send, {vk31 Up}

}



{
 ControlSend,, {vk32 Down}, ahk_class SimWindow 
 KeyWait, vk71
 Sleep 3150
 Send, {Up vk32}
}


{
 ControlSend,, {vk33 Down}, ahk_class SimWindow
 Sleep 3150 
 KeyWait, vk71
 Send, {Up vk33}
}
{
 ControlSend,, {vk34 Down}, ahk_class SimWindow
 Sleep 3150 
 KeyWait, vk71
 Send, {vk34 Up}
}

}
return
vk73::Pause
April 4th 20 at 00:40
1 answer
April 4th 20 at 00:42
Solution
Can be written to ahk_pid, ahk_id (hWnd). Googling how to work with a specific class (I personally couldn't).
Got to do the binding via ahk_id .
But every time you start the game - id is changing .
Try to tie the code from the wiki , which looks up a list of all open Windows and shows their ID .
That's just shows how ID fit in the top code , I don't know - niko98 commented on April 4th 20 at 00:45
Make a mini GUI with plenty of Windows and podstawy then there - mattie_Hil commented on April 4th 20 at 00:48

Find more questions by tags ProgrammingMacrosBotsAutoHotkey