Idle Clicker Game

Ask gaming related questions
Fotarastm
Posts: 1
Joined: 04 Dec 2023, 16:39

Idle Clicker Game

Post by Fotarastm » 04 Dec 2023, 16:43

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.

niCode
Posts: 327
Joined: 17 Oct 2022, 22:09

Re: Idle Clicker Game

Post by niCode » 04 Dec 2023, 21:34

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:

Code: Select all

F1:: {
    static toggle := false
    SetTimer(() => SendEvent('{Space}'), 30 * (toggle ^= 1))
}
Ideally you would wrap this in a #HotIf so the hotkey only works when the game is focused, like this:

Code: Select all

#HotIf WinActive('ahk_exe YourGame.exe')
F1:: {
    static toggle := false
    SetTimer(() => SendEvent('{Space}'), 30 * (toggle ^= 1))
}
#HotIf
Obviously replacing YourGame.exe with the game's actual .exe name.

User avatar
boiler
Posts: 17710
Joined: 21 Dec 2014, 02:44

Re: Idle Clicker Game

Post by boiler » 05 Dec 2023, 00:15

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.
A 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.

niCode
Posts: 327
Joined: 17 Oct 2022, 22:09

Re: Idle Clicker Game

Post by niCode » 05 Dec 2023, 02:30

boiler wrote:
05 Dec 2023, 00:15
A 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.
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!

Post Reply

Return to “Gaming”