Loop Send when Modifier and Mouse Button Held

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
thumped
Posts: 2
Joined: 04 Dec 2022, 02:00

Loop Send when Modifier and Mouse Button Held

Post by thumped » 04 Dec 2022, 02:54

Hello everyone,

I've been scowering the internet trying to figure this one out and the struggle is real....

The goal:

I Hold down Rbutton and it sends a keystroke repeatedly (ex: Hold Right Mouse and send "6" keystoke.

Now if I press Shift while holding down Rbutton, it sends Shift+6 (+6)

if I press Alt while holding down Rbutton send Alt+6

if I press Ctrl while holding down Rbutton send Ctrl +6

Essentially as long as Im holding Rbutton, 6 should be sending in some form, 6 or ^6 or !6 or +6, as a loop




My latest attempt is below; I have gotten the Alt+Right Click to send 6 but not repeating.... been trying to babystep my way there but no luck.

Any more intelligent/capable individuals wanting to give their input would be greatly appreciated... im a noob and this is what i've figured out in the last 10 hours...sad i know.



Code: Select all

#IfWinActive
#SingleInstance force
#NoEnv  
#Warn  
#Persistent 
#MaxThreadsPerHotkey 2

#IfWinActive
~End::
WinActivate ahk_exe notepad++.exe
return	
#ifwinactive ahk_exe notepad++.exe
~^s::
reload
return
#ifwinactive

<!RButton::    ; Alt + Left Mouse Button
if GetKeyState("LAlt","p")   ; Repeat as long as Left Alt Button is held down
{
	if GetKeyState("Rbutton","p") ;repeat as long as Left alt AND Rbutton are held down
	{
		send 6
	} 
		else 
		{
			msgbox, no Rbutton
		}
	Return 
			
}
	else 
	{
	msgbox, No Left Alt
	
	}
Return
[Mod edit: [code][/code] tags added.]

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

Re: Loop Send when Modifier and Mouse Button Held

Post by mikeyww » 04 Dec 2022, 08:57

Welcome to this AutoHotkey forum!

Did the Web sites of your search include the AutoHotkey documentation?

Code: Select all

*RButton::
While GetKeyState("RButton", "P")
 Send {Blind}6
Return
Explained: Blind mode

thumped
Posts: 2
Joined: 04 Dec 2022, 02:00

Re: Loop Send when Modifier and Mouse Button Held

Post by thumped » 04 Dec 2022, 11:21

Yeah... so I saw blinds in the documentation and, probably my lack of understanding - but I am/was under the impression that blind DIDNT work with modifiers or at least not with Modifiers and Mouse buttons due to hook limitations???? (totally lost).... but after having tested I see i was completely wrong. I'll have to watch some videos on blinds cuz I'm still lost to how it works exactly.

Thanks though - just got to keep stumbling my way through!

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

Re: Loop Send when Modifier and Mouse Button Held

Post by mikeyww » 04 Dec 2022, 11:38

A clue.....
The Blind mode avoids releasing the modifier keys (Alt, Ctrl, Shift, and Win) if they started out in the down position. For example, the hotkey +s::Send {Blind}abc would send ABC rather than abc because the user is holding down Shift.
Explained: Wildcard
Wildcard: Fire the hotkey even if extra modifiers are being held down.

Post Reply

Return to “Ask for Help (v1)”