Simple script - can't make it :(

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
IBlackMambaI
Posts: 1
Joined: 04 Oct 2022, 13:47

Simple script - can't make it :(

Post by IBlackMambaI » 04 Oct 2022, 14:13

Hello all,

I'm currently trying to achieve the following but somehow struggling hard:
Whenever I have key "Left Alt" pressed down and once the left mouse button is pressed (by myself) - while LAlt is still down - there should be only one left mouse button click event - for a certain amount of time. Once that time has passed, a new left mouse click event is allowed to be processed. Button "Left Alt" keeps being pressed all the time.

My try looks like the following:

Code: Select all

LButton::

	if (GetKeyState("LAlt", "P"))
	{
		Send {LButton}
		Sleep 100
		
	}
	else
	{
		Send {LButton}
	}

return

Would be awesome if you can tell me what I'm currently doing wrong. Thing is, it somehow is working, though the opposite :crazy: i.e. whenever I press LAlt, it's doing what should be done if LAlt isn't pressed.


[Mod edit: Added [code][/code] tags. Please use them yourself when posting code.]

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

Re: Simple script - can't make it :(

Post by mikeyww » 04 Oct 2022, 17:20

Welcome to this AutoHotkey forum!

If you want to press a modifier key with another key, then the hotkey should refer to both.

Code: Select all

<!LButton::
If (end < now := A_TickCount) {
 Click
 end := now + 100
}
Return
This might work, depending on the situation.

Code: Select all

<!LButton::
Click
Sleep, 100
Return

Post Reply

Return to “Ask for Help (v1)”