Remapped modifier key not firing for HotIf variant Topic is solved

Report problems with documented functionality
Federhalter
Posts: 13
Joined: 07 Sep 2022, 04:04

Remapped modifier key not firing for HotIf variant

24 Aug 2023, 05:40

I tried to map a key to behave like an additional Shift key. In addition, I also want to use conditional hotkeys (for demonstration, I have used a static condition which is always true here)

Code: Select all

some_condition := true

sc056::LShift

#HotIf (some_condition)
+a:: Send "Ä"
a:: Send "ä"
When pressing sc056 + a, I get "ä" but expected "Ä".

I found that by adding a corresponding unconditional hotkey, the problem can be prevented.

The following works, but it is not what I want: I do not want to remap 'a' unconditionally - it should perform the standard action. Here sc056 + a yields the expected "Ä".

Code: Select all

some_condition := true

sc056::LShift
+a:: Send "{Text}A"
a:: Send "{Text}a"

#HotIf (some_condition)
+a:: Send "Ä"
a:: Send "ä"
In v1 the following works as expected:

Code: Select all

some_condition := false

sc056::LShift

#If (some_condition)
+a:: Send Ä
a:: Send ä
This seems like a bug in v2.
User avatar
emmanuel d
Posts: 90
Joined: 17 Nov 2013, 04:45

Re: Remapped modifier key not firing for HotIf variant

30 Aug 2023, 09:41

this works as expected in V2

Code: Select all

#Requires AutoHotkey v2.0
#SingleInstance force   
#Warn All
some_condition := true
#HotIf                                            ; Hotkey for all windows
b::LShift                                         ; Maybe the sc nr is the bug
#HotIf (some_condition)                           ; Hotkey If condition is true
+a::Send("Ä")                                     ; Press b & a gives Ä 
a::Send("ä")                                      ; press a Gives ä 
lexikos
Posts: 9688
Joined: 30 Sep 2013, 04:07
Contact:

Re: Remapped modifier key not firing for HotIf variant

31 Aug 2023, 04:48

I doubt this is a bug. Your code works fine for me.

Is there some reason that you use {Text} for "a" but not for "ä"?

If you use Text mode, it will not trigger certain types of keyboard shorcuts. This may or may not be desirable.

If you do not use Text mode, it will try to map the character to a key or key combination, so may give different results on different keyboard layouts. I'm guessing your keyboard layout doesn't have "ä" and that's why you're sending it. I tested on both the US (which does not have ä) and German (which has ä) layouts.

Also, SendText "a" is more efficient than Send "{Text}a" but does the same thing.
Federhalter
Posts: 13
Joined: 07 Sep 2022, 04:04

Re: Remapped modifier key not firing for HotIf variant

31 Aug 2023, 05:26

emmanuel d wrote:
30 Aug 2023, 09:41
this works as expected in V2

Code: Select all

#Requires AutoHotkey v2.0
#SingleInstance force   
#Warn All
some_condition := true
#HotIf                                            ; Hotkey for all windows
b::LShift                                         ; Maybe the sc nr is the bug
#HotIf (some_condition)                           ; Hotkey If condition is true
+a::Send("Ä")                                     ; Press b & a gives Ä 
a::Send("ä")                                      ; press a Gives ä 
Does not work for me. When I download and run your script with "C:\...\v2\AutoHotkey64.exe test.ahk", pressing b & a gives ä.

b & c -> C (as expected), LShift & a -> Ä.

I tried on two different machines (running Windows 10 21H2 and 22H2) and AHK 2.0.6 and tried to close all programs which also might interfere with hotkeys.

Same result for US and German keyboard layout.
Federhalter
Posts: 13
Joined: 07 Sep 2022, 04:04

Re: Remapped modifier key not firing for HotIf variant

31 Aug 2023, 11:29

Federhalter wrote:
31 Aug 2023, 05:26
emmanuel d wrote:
30 Aug 2023, 09:41
this works as expected in V2

Code: Select all

#Requires AutoHotkey v2.0
#SingleInstance force   
#Warn All
some_condition := true
#HotIf                                            ; Hotkey for all windows
b::LShift                                         ; Maybe the sc nr is the bug
#HotIf (some_condition)                           ; Hotkey If condition is true
+a::Send("Ä")                                     ; Press b & a gives Ä 
a::Send("ä")                                      ; press a Gives ä 
Does not work for me. When I download and run your script with "C:\...\v2\AutoHotkey64.exe test.ahk", pressing b & a gives ä.

b & c -> C (as expected), LShift & a -> Ä.

I tried on two different machines (running Windows 10 21H2 and 22H2) and AHK 2.0.6 and tried to close all programs which also might interfere with hotkeys.

Same result for US and German keyboard layout.
By accident I also discovered that the bug does not occur, if another AHK v1 or v2 script with a keyboard hook is running at the same time, e.g.

Code: Select all

#SingleInstance force   
#Warn All
#InstallKeybdHook

Code: Select all

#Requires AutoHotkey v2.0
#SingleInstance force   
#Warn All
InstallKeybdHook
Persistent
lexikos
Posts: 9688
Joined: 30 Sep 2013, 04:07
Contact:

Re: Remapped modifier key not firing for HotIf variant

31 Aug 2023, 20:58

Federhalter wrote:
31 Aug 2023, 11:29
By accident I also discovered that the bug does not occur, if another AHK v1 or v2 script with a keyboard hook is running at the same time, e.g.
:shock:

The penny just dropped.

Your issue is the same as Alt::LWin LWin::Alt problem. This bug has existed for over 17 years, and has only been properly identified last night. It will be fixed in the next update.

Return to “Bug Reports”

Who is online

Users browsing this forum: No registered users and 8 guests