Best Answer
ControlSend [, Control, Keys, WinTitle, WinText, ExcludeTitle, ExcludeText]
In this case, there is no control, we're just sending to the window, so we'll leave it blank. The key is space. For the WinTitle, we'll use the class, since it's typically more consistent. Put it together: ControlSend,, {Space}, ahk_class SDL_app
If we have multiple windows to send to, we need to have another form of identification for them. We can use WinGet for this.
WinGet, winList, List, ahk_class SDL_app ; grab all window handles (hwnds) that match the class. Hwnds, or window ID's, are unique in that no two can have the same ID at the same time.
Loop % winList ; now contains the number of windows matched
ControlSend,, {Space},% "ahk_id " winList%a_index% ; starting a parameter with % forces expression syntax. This loop structure effectively sends a space to all windows that previously matched the class name.
And putting it all together, along with a timer (pre-directives (specified by a preceding #) only affect hotkeys and hotstrings). Checking if it's active isn't needed here; if WinGet finds no windows, it will loop for 0 iterations.
#Persistent
SetTimer, noafk, 10000 ; run label "noafk" at 10000 ms intervals
return
noafk:
WinGet, winList, List, ahk_class SDL_app
Loop % winList
ControlSend,, {Space},% "ahk_id " winList%a_index%
return
It's often games don't accept ControlSend, so don't worry if this doesn't readily work.