Page 1 of 1

Press Left click while holding spacebar

Posted: 27 Sep 2021, 16:08
by speshulk926
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

Re: Press Left click while holding spacebar  Topic is solved

Posted: 27 Sep 2021, 16:15
by mikeyww

Code: Select all

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

Re: Press Left click while holding spacebar

Posted: 27 Sep 2021, 16:19
by speshulk926
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!