Page 1 of 1

Self-remapping with #Inputlevel

Posted: 14 Sep 2018, 08:59
by Nextron
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

Re: Self-remapping with #Inputlevel

Posted: 14 Sep 2018, 17:17
by lexikos
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.

Re: Self-remapping with #Inputlevel  Topic is solved

Posted: 11 Nov 2018, 02:02
by lexikos
v1.1.30.01 fixes this.