Self-remapping with #Inputlevel Topic is solved

Report problems with documented functionality
User avatar
Nextron
Posts: 1275
Joined: 01 Oct 2013, 08:23
Location: Netherlands OS: Win7 x64 AHK: Unicode x32

Self-remapping with #Inputlevel

14 Sep 2018, 08:59

Remappings translate into two hotkeys and the default #Inputlevel is 0. So a remapping a::b works the same as

Code: Select all

#InputLevel 0
*a::
SetKeyDelay -1   ; If the destination key is a mouse button, SetMouseDelay is used instead.
Send {Blind}{b DownR}  ; DownR is like Down except that other Send commands in the script won't assume "b" should stay down during their Send.
return

*a up::
SetKeyDelay -1  ; See note below for why press-duration is not specified with either of these SetKeyDelays.
Send {Blind}{b up}
return
Which works, regardless of the #Inputlevel because it shouldn't change the (lack of) interaction since:
• "The input level of a hotkey or non-auto-replace hotstring is also used as the default send level for any keystrokes or button clicks generated by that hotkey or hotstring." and
• "For any event generated by a script to trigger a hook hotkey or hotstring, the send level of the event must be higher than the input level of the hotkey or hotstring."

However, the remapping a::a works too (I'm not actually using that, rather the two hotkeys above with some conditional stuff added). However, when you change the #InputLevel, it doesn't output anything anymore. Even though Key History shows the same regardless of of the level:

Code: Select all

41  01E	h	d	5.00	a              	
41  01E	i	d	0.00	a              	
41  01E	h	u	0.05	a              	
41  01E	i	u	0.00	a
This doesn't work and instead blocks a:

Code: Select all

InputLevel 1 ;0 works, 1 doesn't
*a::
SetKeyDelay -1   ; If the destination key is a mouse button, SetMouseDelay is used instead.
Send {Blind}{a DownR}  ; DownR is like Down except that other Send commands in the script won't assume "b" should stay down during their Send.
return

*a up::
SetKeyDelay -1  ; See note below for why press-duration is not specified with either of these SetKeyDelays.
Send {Blind}{a up}
return
lexikos
Posts: 6207
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Re: Self-remapping with #Inputlevel

14 Sep 2018, 17:17

Normally "ignored" events are unconditionally marked as such by having one of a few different special values attached to the event. The keyboard hook returns early for these events, allowing them to pass through regardless of what hotkeys are defined, since they never trigger hotkeys. SendLevel extends this with values that cannot prevent the hook from processing the event, but may prevent the hotkey firing (once the event is matched to a hotkey), more like #if than an ignored event.

When you press a down-hotkey that is disabled by #if, if that down-hotkey has a corresponding up-hotkey which is enabled, the event must be suppressed. Otherwise when the up-hotkey executes, it will either be unable to suppress the up event or the key will get stuck down.

In other words, when you send {a DownR},
  • it is matched up to the hotkey pair *a and *a up,
  • the hotkey *a is prevented from firing due to SendLevel vs. #InputLevel,
  • the hotkey *a up is seen as enabled, so the event is suppressed.
When you send {a up},
  • the hotkey *a up is prevented from firing due to SendLevel vs. #InputLevel,
  • the event is suppressed because the corresponding down event was suppressed.
I will change it to not suppress either event when the hotkey is prevented from firing due to SendLevel vs. #InputLevel.
lexikos
Posts: 6207
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Re: Self-remapping with #Inputlevel  Topic is solved

11 Nov 2018, 02:02

v1.1.30.01 fixes this.

Return to “Bug Reports”

Who is online

Users browsing this forum: No registered users and 1 guest