Press Left click while holding spacebar Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
speshulk926
Posts: 2
Joined: 27 Sep 2021, 15:51

Press Left click while holding spacebar

Post by speshulk926 » 27 Sep 2021, 16:08

I'm looking to have it constantly click Left Mouse while holding spacebar inside of a specific app. I need it only in that app because when out of the app I need to use spacebar like normal and trying not to toggle on and off. Here's the code I have. It does spam left click, but then couldn't get it to stop. I got the original code from here: https://autohotkey.com/board/topic/41742-spamming-left-clicks-when-mouse-button-hold-down/, however instead of "while mouse held down" I need "while space held down". I got the title stuff from here: https://www.autohotkey.com/docs/commands/WinGetActiveTitle.htm

Current code:

Code: Select all

$Space::
WinGetActiveTitle, Title
Loop
{
if not GetKeyState("Space", "P") and Title = "AppName"
break
Click
}
return

User avatar
mikeyww
Posts: 26601
Joined: 09 Sep 2014, 18:38

Re: Press Left click while holding spacebar  Topic is solved

Post by mikeyww » 27 Sep 2021, 16:15

Code: Select all

#IfWinActive ahk_exe notepad.exe
Space::
While GetKeyState(A_ThisHotkey, "P") {
 Click
 Sleep, 15
}
Return
#IfWinActive

speshulk926
Posts: 2
Joined: 27 Sep 2021, 15:51

Re: Press Left click while holding spacebar

Post by speshulk926 » 27 Sep 2021, 16:19

mikeyww wrote:
27 Sep 2021, 16:15

Code: Select all

#IfWinActive ahk_exe notepad.exe
Space::
While GetKeyState(A_ThisHotkey, "P") {
 Click
 Sleep, 15
}
Return
#IfWinActive
This is clean and works well!

Post Reply

Return to “Ask for Help (v1)”