Send {Shift up} doesn't release shift when called in the first lines of a hotkey defined with +

Report problems with documented functionality
zebluk
Posts: 6
Joined: 23 May 2017, 18:49

Send {Shift up} doesn't release shift when called in the first lines of a hotkey defined with +

26 May 2017, 09:35

This code should allow to release Shift by pressing F2, but it doesn't:

Code: Select all

F1::
  Send {Shift down}
return

+F2::
  Send {Shift up}
return
However this code works:

Code: Select all

F1::
  Send {Shift down}
return

+F2::
  Sleep, 100
  Send {Shift up}
return
And this works as well:

Code: Select all

F1::
  Send {Shift down}
return

*F2::
  Send {Shift up}
return
Last edited by zebluk on 27 May 2017, 04:32, edited 2 times in total.
zebluk
Posts: 6
Joined: 23 May 2017, 18:49

Re: Send {Shift up} doesn't release shift when called in the first lines of a hotkey defined with +

26 May 2017, 09:50

One of the workarounds is to add {Blind} before releasing

Code: Select all

Send {Blind}{z up}{Shift up}
However in the first example, if you press F1, then pressing F2 won't release the key (don't press shift F2, only F2, the + is there to take the shift down into account)
zebluk
Posts: 6
Joined: 23 May 2017, 18:49

Re: Send {Shift up} doesn't release shift when called in the first lines of a hotkey defined with +

26 May 2017, 10:09

Well it's even more strange then, it doesn't work here. I'm currently on #ahk on IRC and other people reported the same weird behavior. Maybe a different OS? I'm running Win 7 x64
IMEime
Posts: 750
Joined: 20 Sep 2014, 06:15

Re: Send {Shift up} doesn't release shift when called in the first lines of a hotkey defined with +

26 May 2017, 10:19

What do you mean by doesn't work ?
What do you expect AHK to do after you commanded to press shift key firmly?

At that moment if you press F2 that results Shift+F2.
In that situation there is no way to make the same effect as press (sheer) F2.

Regards
zebluk
Posts: 6
Joined: 23 May 2017, 18:49

Re: Send {Shift up} doesn't release shift when called in the first lines of a hotkey defined with +

26 May 2017, 10:28

An example scenario:

I open notepad and type some random text, then I press F1.
To test that shift is effectively down, I left click at various places of the text: instead of moving the cursor, it selects the text from where the cursor was prior to pressing F1, confirming that shift is down.
Now I press F2 (without pressing shift as it's already down virtually), and click some text, expecting the cursor to move where I click, however it keeps selecting text, because shift was not released despite the Send {Shift up}.

The code from F2:: is actually run (tested with logging), but the Send {Shift up} doesn't apply correctly (it looks like it's sent, but immediately pressed again for some reason).
zebluk
Posts: 6
Joined: 23 May 2017, 18:49

Re: Send {Shift up} doesn't release shift when called in the first lines of a hotkey defined with +

26 May 2017, 10:56

Helgef wrote:You might be interested in #HotkeyModifierTimeout.
#HotkeyModifierTimeout seems to be the reason for this behaviour, thanks. Setting #HotkeyModifierTimeout to 0 solves this problem.

So it's actually not a bug, but a consequence of the design behind HotKey management with Sends inside. Not intuitive, thanks for having shed some light on this!

Can we say "solved" ?
zebluk
Posts: 6
Joined: 23 May 2017, 18:49

Re: [solved] Send {Shift up} doesn't release shift when called in the first lines of a hotkey defined with +

27 May 2017, 04:32

After some re-thinking and despite Helgef great answer, I still think there's something fishy.

I understand why a mechanism like #HotkeyModifierTimeout is needed, AHK want to send clean stuff and has to release modifier keys before Sends, and press them back after it's done.

However, in the case of releasing a modifier key like {Ctrl up} {Shift up} and {Alt up}, the "auto press it down after Send" should probably NOT press back any modifier that was explicitly released in the Send keys. This is why I think it's not a problem with design after all, but a bug, and I'm removing [solved] from the title -- for now.

Return to “Bug Reports”

Who is online

Users browsing this forum: ZhuangQu and 15 guests