Hello there, im new to ahk and i wanna make a script for an idle clicking game that spams SPACE or MOUSE1(I guess that would require for the window to be active!?) when the game is in background/minimized.
I did some research in documentation, with ControlSend but i didnt manage to make it.
Idle Clicker Game
Re: Idle Clicker Game
The game would need to use the built-in Windows controls for ControlSend to work, I believe. So if nothing is reported next to ClassNN when using AutoHotkey Window Spy on the game window, I don't believe you can send things to the window when its unfocused. That's my understanding anyway.
But you could use this when the game is in focus to spam Space:
Ideally you would wrap this in a #HotIf so the hotkey only works when the game is focused, like this:
Obviously replacing YourGame.exe with the game's actual .exe name.
But you could use this when the game is in focus to spam Space:
Code: Select all
F1:: {
static toggle := false
SetTimer(() => SendEvent('{Space}'), 30 * (toggle ^= 1))
}
Code: Select all
#HotIf WinActive('ahk_exe YourGame.exe')
F1:: {
static toggle := false
SetTimer(() => SendEvent('{Space}'), 30 * (toggle ^= 1))
}
#HotIf
Re: Idle Clicker Game
A window does not need to have controls for ControlSend to work. Per the documentation:niCode wrote: ↑ The game would need to use the built-in Windows controls for ControlSend to work, I believe. So if nothing is reported next to ClassNN when using AutoHotkey Window Spy on the game window, I don't believe you can send things to the window when its unfocused. That's my understanding anyway.
Remarks section of ControlSend wrote:If the Control parameter is omitted, this function will attempt to send directly to the target window by sending to its topmost control (which is often the correct one) or the window itself if there are no controls. This is useful if a window does not appear to have any controls at all, or just for the convenience of not having to worry about which control to send to.
Re: Idle Clicker Game
Ah, this is good to know. I've never been able to think of any good uses for ControlSend for myself personally, therefore I don't have much experience with it; so I'm just going off what I've seen regurgitated somewhere. That'll teach me to not do my research. Thanks!boiler wrote: ↑05 Dec 2023, 00:15A window does not need to have controls for ControlSend to work. Per the documentation:Remarks section of ControlSend wrote:If the Control parameter is omitted, this function will attempt to send directly to the target window by sending to its topmost control (which is often the correct one) or the window itself if there are no controls. This is useful if a window does not appear to have any controls at all, or just for the convenience of not having to worry about which control to send to.