Auto hot key crew

My goal is to get this script working, but not requiring the window to be focused. i.e i can browse web while this thign spams the enter key.

the current script:
#singleInstance, Force
#MaxThreadsPerHotkey, 2
SetBatchLines, -1
DetectHiddenWindows, On
CoordMode, Mouse, Screen
CoordMode, Pixel, Screen
CoordMode, Tooltip, Screen
SetTitleMatchMode, 2
SetKeyDelay, 30,50
SetMouseDelay 10
SendMode Event
#UseHook, On

jtoggle = 0

while (1)
{ If (jtoggle)
{ send, {Enter}
sleep, 500

jtoggle := !Jtoggle


i’ve tried playing around with another script i found which uses something called controlsend. it works perfectly for notepad.. but for my game it doesnt. at first i thought it was because the ahk class for my game is 2 words and the notepad thing is only one. i messed around with process id instead and it also works perfectly for notepad but not for my game?

any idea why the first script works but controlsend or w/e doesnt? any way to resolve the first script so it can work while not focused?

here’s the second script that i got workign with notepad but not the game. the game name is arma 3 btw.

VarContainingPID := 10064
ControlSend, , {Space}, ahk_pid %VarContainingPID%,
sleep, 500