LControl + mouse click problem

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
paik1002
Posts: 355
Joined: 28 Nov 2015, 02:45

LControl + mouse click problem

23 Apr 2017, 13:40

I would like LControl to:
(1) function as a hotkey when pressed solely by itself(LControl down and up), and
(2) retain its native function as a modifier key as well, when pressed in combination with another key.

However, the following script does not seem to function correctly for: LControl + mouse button.
It will perform the native function but will also trigger LControl as hotkey, unless #KeyHistory=1.
However, if #KeyHistory=1, LControl will not function as a modifier to a keyboard key.

Is there a way to fix this problem by modifying the following script?
Help would be appreciated.

Code: Select all

#KeyHistory=5
; #KeyHistory=1

~LControl::
{
    KeyWait, LControl                       ; wait for LCtrl to be released
    if A_PriorKey = LControl                ; hotkey mode
    {
    	tooltip LControl is a hotkey
    }
    else                                    	; native mode
    {
    	tooltip LControl is a modifier
    }
    return
}
GEV
Posts: 1002
Joined: 25 Feb 2014, 00:50

Re: LControl + mouse click problem

23 Apr 2017, 15:54

The tilde prefix (~) prevents AHK from blocking the key-down/up events.
Try it this way:

Code: Select all

; (1) function as a hotkey when pressed solely by itself:

LControl Up::
	tooltip LControl is a hotkey        ; do sth
	Sleep, 1500
	tooltip
return

; (2) retain its native function as a modifier key as well, when pressed in combination with another key:

<^LButton::					; <^ means LControl
	tooltip, LControl + LButton  	; do sth
	Sleep, 1500
	tooltip
return

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Google [Bot], jeves, mikeyww, Thorlian and 284 guests