Page 1 of 1

2-Key Custom Combinations Activating Other Hotkeys

Posted: 29 Jul 2021, 17:59
by BeyondDNA2021
Hello, I defined a custom combination of two keys by using the "&" character, and when I execute the hotkey, it activates the hotkey associated with the second key from the key combination.

Specifically, when I execute the hotkey "Esc & F1", it also executes the hotkey "F1" at the same time.

I believe this is related to the fact that "custom combinations act as though they have the wildcard (*) modifier by default".

Is this the problem? If so, how can I disable this wildcard behavior with 2-key custom combinations?

Re: 2-Key Custom Combinations Activating Other Hotkeys  Topic is solved

Posted: 29 Jul 2021, 19:34
by BeyondDNA2021
Well this is embarrassing. I figured out my problem. My script was doing this behavior because I did not include a "return" line at the end of my hotkey.

Re: 2-Key Custom Combinations Activating Other Hotkeys

Posted: 16 Feb 2022, 10:21
by jbone1313
I am having this exact problem. But, unlike the OP, including a return is not helping.

Below is a simplified version of my code just to highlight the issue.

When I hold down Enter, then press and release f, then release Enter, a blank notepad.exe is launched as expected.

But, if I am lazy and very quickly press Enter & f, notepad.exe is launched, but a f is then typed in the opened notepad.

I have tried all sorts of KeyWait and Sleep ideas, but nothing helps.

It is as if AutoHotKey is processing both the "Enter & f" and the "f up" hotkeys defined below. But again, it only does that when I type "Enter & f" very quickly.

Any thoughts or ideas would be very appreciated.

Code: Select all

Enter::Enter

Enter & f::
 	Run notepad.exe
return	

f::
return	

f up::
	if (GetKeyState("Enter","P") = false)
		Send f	 
return

Re: 2-Key Custom Combinations Activating Other Hotkeys

Posted: 16 Feb 2022, 10:43
by jbone1313
I figured it out.

Replacing this:

Code: Select all

if (GetKeyState("Enter","P") = false)
With this:

Code: Select all

if (A_PriorHotKey != "Enter & " A_PriorKey)
Is the answer.