trying to make a key toggle holding another key Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
qq504756010
Posts: 1
Joined: 27 Jul 2021, 20:03

trying to make a key toggle holding another key

Post by qq504756010 » 27 Jul 2021, 20:11

Hi,

trying to make a key toggle holding another key, below works. But sometimes I would be pressing Lctrl (to crouch in game) when I click RButton, then it would no longer work.

Code: Select all

RButton::
KeyDown := !KeyDown
If KeyDown
	SendInput {F7 down}
Else
	SendInput {F7 up}
Return
I tried below, it works but it would interfere with my Lctrl (crouch) momentarily, is there any other way to make RButton always trigger the toggle, no matter what other keys I was already pressing at the same time?

Code: Select all

LCtrl & RButton::
KeyDown := !KeyDown
If KeyDown
	SendInput {F7 down}
Else
	SendInput {F7 up}
Return
[Mod edit: [code][/code] tags added.]

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

Re: trying to make a key toggle holding another key  Topic is solved

Post by mikeyww » 27 Jul 2021, 21:12

With the "*" wildcard, *RButton will trigger with any modifier.

Code: Select all

*RButton::
Send % GetKeyState("F7") ? "{F7 up}" : "{F7 down}"
SoundBeep, 1500 - 500 * GetKeyState("F7")
Return

Post Reply

Return to “Ask for Help (v1)”