Attempting to hold a button and then hold another button with it a second or 2 later

Ask gaming related questions (AHK v1.1 and older)
SlagbagProHag
Posts: 2
Joined: 15 Feb 2018, 13:36

Attempting to hold a button and then hold another button with it a second or 2 later

15 Feb 2018, 13:42

Hi,

I'm an AutoHotKey novice, I'm attempting to write a script that when my Right Mouse Button is pressed and held it performs the function the right mouse button is binded to, but a second later it then holds my left shift down and then when I release the Right mouse button, it acts as though both keys have been released.

I have written the below, but it doesn't work everytime and sometimes it doesn't pick up I have released the Right Mouse Button and I have to hit the Right Mouse Button again.

Can anyone help please.

Code: Select all

RButton::
;Send {LShift down}{RButton down}
Send {RButton down}
Sleep 2000
Send {LShift down}
While GetKeyState(RButton, "p")
Send {LShift up}{RButton up}
Return
Rohwedder
Posts: 7616
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Attempting to hold a button and then hold another button with it a second or 2 later

16 Feb 2018, 02:42

Hallo,
try:

Code: Select all

~RButton:: ;"~": When the hotkey fires, its key's native function will not be blocked
Sleep 2000
If GetKeyState("RButton")
{
	Send {LShift down}
	KeyWait, RButton
	Send {LShift up}
}
Return
You forgot the quotemarks from RButton in GetKeyState("RButton", "p")
pumpkinking2
Posts: 1
Joined: 25 Jan 2023, 21:19

Re: Attempting to hold a button and then hold another button with it a second or 2 later

25 Jan 2023, 21:25

Hi
so i was trying to figure this out to make a shiftlock.
i tried replacing the buttons and it doesnt work i dont now much about autohotkey and i was wondering what i did wrong

Code: Select all

~w:: ;"~": When the hotkey fires, its key's native function will not be blocked
Sleep 2000
If GetKeyState("w")
{
	Send {Click down right}
	KeyWait, W
	Send {Click up right}
}
Return
User avatar
DuckingQuack
Posts: 219
Joined: 20 Jan 2023, 18:20

Re: Attempting to hold a button and then hold another button with it a second or 2 later

28 Jan 2023, 21:55

@pumpkinking2 This will create a shiftlock that operates like capslock (same button toggles it's own effect). The Esc function was added with a shift up because exiting the app would not turn the toggle off by itself and shift toggled on can cause a wide variety of alternate commands to happen when trying to navigate windows.

Code: Select all

#Requires AutoHotkey v2.0
*Esc::{
	Send "{Shift Up}"
	ExitApp
}	
*Shift::{
	If GetKeyState("Shift", "T"){ 
		Send "{Shift Up}"
	}Else Send "{Shift Down}"
}
Best of Luck,
The Duck

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: No registered users and 37 guests