Testing needed with hotkeys, esp. custom combos and ~

Community news and information about new or upcoming versions of AutoHotkey
Post Reply
lexikos
Posts: 9553
Joined: 30 Sep 2013, 04:07
Contact:

Testing needed with hotkeys, esp. custom combos and ~

Post by lexikos » 25 Apr 2021, 19:26

I have uploaded a test build based on commit a6a1a580, which changes the behaviour of the no-suppress (~) prefix slightly, from:
if a tilde is applied to the prefix key of any custom combination which has not been turned off or suspended, it affects the behavior of that prefix key for all combinations.
to
if a tilde is applied to the prefix key of any custom combination which has not been disabled by #If, turned off or suspended, it affects the behavior of that prefix key for all combinations.
For some context, see Tilde modifier and #If directives.

Download
ahk7
Posts: 574
Joined: 06 Nov 2013, 16:35

Re: Testing needed with hotkeys, esp. custom combos and ~

Post by ahk7 » 06 May 2021, 12:14

Took me a few days to notice but in one of my scripts the user can define Esc & hotkey and when they do I use the ~ as the ESC key is also needed to be able to close windows & actions in the program (Total Commander and various child windows) - I've isolated the hotkey setup from my script. Up till now the "hotkey" was blocked e.g. the "a" wasn't sent to notepad, but with the test version the "a" does appear in the notepad window.

Not sure if my original solution was actually faulty and the new behaviour is correct, but just in case (code isn't pretty):

Code: Select all

#NoEnv
#SingleInstance, force

; ~ native function will not be blocked 
; $ prefix forces the keyboard hook to be used to implement this hotkey

; notepad as test here, but in my script a group of windows which require ESC close the window/cancel action
Hotkey, IfWinActive, ahk_exe notepad.exe 

hk_prefix:="$"
FGHKey:="Esc & a" 
HotKeyState:="On"

; source of FGHKey is a setting from an XML file hence the replacements to prevent errors
StringReplace, FGHKey, FGHKey, &amp`;amp`;, & , All
StringReplace, FGHKey, FGHKey, &amp`;, &, All

If (InStr(FGHKey,"ESC")) ; needed so we can still use ESC to close/cancel
	hk_prefix:="~"

Hotkey, % hk_prefix FGHKey, TestLabel, %HotKeyState%  ; %

Return

TestLabel:
MsgBox % A_AhkVersion
Return

Result until and including 1.1.33.08 -> Just show MsgBox

Results 1.1.34-TEST+ga6a1a580 -> Shows MsgBox BUT also allows 'a' to be sent to Notepad window, this is a change in behaviour compared to all previous versions.
lexikos
Posts: 9553
Joined: 30 Sep 2013, 04:07
Contact:

Re: Testing needed with hotkeys, esp. custom combos and ~

Post by lexikos » 06 May 2021, 16:59

That should be fixed now (v1.1.34-TEST+g7377e524). Thanks for reporting it.
ahk7
Posts: 574
Joined: 06 Nov 2013, 16:35

Re: Testing needed with hotkeys, esp. custom combos and ~

Post by ahk7 » 07 May 2021, 12:42

Fix confirmed, thanks!
Post Reply

Return to “Announcements”