Wrong hotkey script triggered

Report problems with documented functionality
cdw3423
Posts: 5
Joined: 10 Dec 2017, 14:43

Wrong hotkey script triggered

14 Dec 2017, 14:53

I have Auto Hotkey V 1.1.26.01 installed on a Windows 7 Machine. With an Intel i5-2500 CPU and 16 gig of ram.

The script that is not working right consists of 256 hotkey definitions. One for every possible modifier key state with the F13 Key. I am using an Adafruit Feather with the 32u4 Arduino processor to emulate a keyboard and send keystrokes to the computer.

After loging all of the keystrokes I send and what hotkey scripts get triggered I have found a pattern. If the keystroke has both the left and right of Ctrl, Shift, Alt, or Win keys, AHK will sometimes ignore either the left or the right modifier key but never both. Also if I am sending the Left and Right of 2 or 3 keys, it will sometimes ignore the left or right of 1, 2 or all 3 of them (most of the time it only ignores one of them). It can sometimes ignore the left of one of them and the right of another. The baffling part is that it is only sometimes. I also discovered if I rearrange the order the hotkey definitions are in the ahk file, the keystrokes that fire incorrectly change.

For example 2 of the hotkey scripts look like this
<^<+<#F13::Send, 011 - LCtrl LShift LWin F 13{enter}
Return
<>^<+<#F13::Send, 027 - LCtrl LShift LWin RCtrl F 13{enter}
Return

When the keystrokes are sent for the second one the first on get's triggered. In this case the right control key is being ignored. The reason I'm 99% sure this is an issue with auto hot key is if I take that first hot string out of the script or just move it to the end, then the second one works correctly. To be clear though this is just a part of the file. I have never tried just those 2 hotkeys in a script. But I have tried to put the hotkeys in different order in a script and when I do, the errors still happen but on different hotkeys. I know that it does work with all modifier keys because this hotkey always fires correctly.

<>^<>+<>!<>#F13::Send, 255 - LCtrl LShift LAlt LWin RCtrl RShift RAlt RWin F 13{enter}
Return

It can happen for very simple cases. For example the LAlt RAlt F13 triggers the RAlt F13 hotkey script. It even happens if I program the Arduino to send keystrokes 10 seconds apart. So how fast I send the keystrokes ins't the issue.


This is for a programmable touchscreen keypad I am working on. To give it more power I want to have it send unused keystrokes to fire AHK hotkeys. Since F13-F24 aren't on any keyboard I have ever seen I figure it is safe to use those. But 12 isn't enough so I am trying to use every modifier key state to give me plenty of options. With not being able to use both the left and right of a give modifier key at the same time, it takes my total number of hotkeys using the F13-F24 from 3072 to 972. I don't think that will be a big deal since I don't think I will ever use that many hotkeys and for simple keyboard macros I don't need to use those keys to trigger a AHK script. But it does seem to be a bug that could come up for some users.

I have attached the AHK scrip I have been using.

Chris W.
F13Hotkeys.ahk
F13 with all 256 possible modifier key states.
(17 KiB) Downloaded 61 times
lexikos
Posts: 9583
Joined: 30 Sep 2013, 04:07
Contact:

Re: Wrong hotkey script triggered

16 Dec 2017, 21:16

Currently a hotkey (without the wildcard modifier) can be activated if all of its left/right-specific modifiers are pressed and the neutral modifier state exactly matches the hotkey's neutral modifiers. For example, <^F13 can be triggered by LCtrl+F13 or LCtrl+RCtrl+F13. I don't know if this was intended, but it clearly hurts flexibility and causes (in some cases) counter-intuitive behaviour. It will be fixed in the next update.

This simple case reproduces the core issue:

Code: Select all

<^1::MsgBox  ; Pressing LCtrl+RCtrl+1 should not trigger this, but it does.
The "sometimes" factor is probably caused by the sorting algorithm not being designed to put <^ and <>^ in any specific order. I see consistent results when I run the script repeatedly without modifying it. You may see similar issues if you use duplicate hotkeys (it is possible to create duplicates by using different key names/vk/sc) or when multiple hotkeys match the pressed modifiers (for example, LCtrl+RCtrl+1 matches *<^1 and *>^1).

FYI, there is no need for return following a single-line hotkey (i.e. when the command is written on the same line as the hotkey label). Return is implied.
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Wrong hotkey script triggered

18 Dec 2017, 06:52

- @cdw3423 and @lexikos: Thanks for these interesting posts.
- Here are three other issues re. AutoHotkey and modifiers.
hotkeys can disable each other - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=5&t=36339
Strange fallback if one more hotkey added - AutoHotkey Community
https://autohotkey.com/boards/viewtopic ... 29#p180029
Problems with own SendInput function - AutoHotkey Community
https://autohotkey.com/boards/viewtopic ... 78#p188678
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
lexikos
Posts: 9583
Joined: 30 Sep 2013, 04:07
Contact:

Re: Wrong hotkey script triggered

27 Dec 2017, 04:43

cdw3423 wrote:
cdw3423, please test your script with v1.1.27.00.

Return to “Bug Reports”

Who is online

Users browsing this forum: No registered users and 39 guests