What i'm trying to do is: sending a bunch of {space} in a game while it is minimized/unfocused
Here's the code i came up with
Code: Select all
#NoEnv
SetKeyDelay, 30, 100,
WinGet, swbpid, PID, STAR WARS Battlefront II
Winget, swbid, ID, STAR WARS Battlefront II
WinGetClass, swbclass, STAR WARS Battlefront II
msgbox, class is %swbclass% pid is %swbpid% and Id is %swbid% ,, just for informations and testing
$*F12::Reload ,, pauses the script
return
$*F11::
if (enable := !enable)
setTimer, MoveAround, -1
return
MoveAround:
while enable
{
ifWinExist, ahk_id %swbid%
{
SetKeyDelay, 30, 100,
ControlSend, , {space}, ahk_id %swbpid%
Sleep, 140
Random, r, 1000, 5000
Sleep r
}
}
return
The thing is, no keystroke is sent....
I know my script is trash and all, but idk why it's not working, it worked in other games! anyone to help please? maybe i'm doing something wrong