Start with my script. Replace my
Send with your
Send. Change "notepad" to "game". Now compare. See the difference from your original?
If you seek an infinite loop:
Code: Select all
F4::
Loop {
WinGet, win, List, ahk_exe game.exe
Loop, %win% {
WinActivate, % "ahk_id " win%A_Index%
Send abc
}
}
Or:
Code: Select all
F4::
WinGet, win, List, ahk_exe game.exe
Loop {
Loop, %win% {
WinActivate, % "ahk_id " win%A_Index%
Send abc
}
Sleep, 500
}
Your script loops through an infinite number of windows that do not exist, because
A_Index continues to increase.