Is this behavior intentional?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
waetherman
Posts: 112
Joined: 05 Feb 2016, 17:00

Re: Is this behavior intentional?

19 Jul 2017, 15:31

To save others some time: When numlock is ON, and numpad inputs numbers, holding shift changes its state back to normal (numlock off), except it then treats the keystrokes as if shift wasn’t pressed, meaning that this shift doesn’t hold the text anchor and so moving the cursor using shift + numpad when numlock is ON will not select the text as it is the case when moving the cursor by using shift + numpad when numlock is off.

Moreover, if you hold both Shifts when numlock is ON, you will select the text, because one shift will invert the numlock state and another will act normally.

Tested on W10.

It’s hard to say if it’s a bug, but I think it’s inconsistent with how AHK does the job for you when you remap a small letter and it automatically remaps a capital letter:

Code: Select all

a::LShift ; works, because A is remapped too, so once shift converts a UP to A UP, it still gets remapped to LShift UP
It also automatically remaps special characters together with digits below them, automatically remaps the question mark with the slash etc. It will even make this work:

Code: Select all

Pause::LCtrl
Even though once you push Pause down, you send LCtrl down, and therefore when you release Pause it actually should be Break Up?

Edit: however, here’s an example that proves consistency in this unexpected behavior:

Code: Select all

While ( 1 ) {
	sleep 100
	ToolTip % GetKeyState( "Numlock" )
}
Numpad7::NumLock
Image
just me
Posts: 9453
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: Is this behavior intentional?

20 Jul 2017, 02:25

Remapping Keys and Buttons
Remarks wrote:When a script is launched, each remapping is translated into a pair of hotkeys. For example, a script containing a::b actually contains the following two hotkeys instead:

Code: Select all

*a::
SetKeyDelay -1   ; If the destination key is a mouse button, SetMouseDelay is used instead.
Send {Blind}{b DownTemp}  ; DownTemp 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
List of Keys, Mouse Buttons, and Joystick Controls
Numpad wrote:Due to system behavior, the following keys are identified differently depending on whether NumLock is ON or OFF. If NumLock is OFF but Shift is pressed, the system temporarily releases Shift and acts as though NumLock is ON.
Now replace a with Numpad0 and b with LShift. What do you expect to happen?
Noesis
Posts: 301
Joined: 26 Apr 2014, 07:57

Re: Is this behavior intentional?

20 Jul 2017, 09:12

just me wrote:List of Keys, Mouse Buttons, and Joystick Controls
Numpad wrote:Due to system behavior, the following keys are identified differently depending on whether NumLock is ON or OFF. If NumLock is OFF but Shift is pressed, the system temporarily releases Shift and acts as though NumLock is ON.
Just reading this part and while I was aware of the behavior, call it a gut feeling, I did some tests, It seems the help is actually back to front here. I believe it should read: "If NumLock is ON but Shift is pressed, the system temporarily releases Shift and acts as though NumLock is OFF." (i.e swapping the on & off around). At least that's how it works for me, When Numlock is OFF, shift acts to shift with the non-numbered numpad keys doing theirs shifted functions.
just me
Posts: 9453
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: Is this behavior intentional?

20 Jul 2017, 15:43

evilC?
Noesis
Posts: 301
Joined: 26 Apr 2014, 07:57

Re: Is this behavior intentional?

21 Jul 2017, 08:01

evilC wrote:I assume the crux of this is the use of DownTemp ? I never used it, haven't really wrapped my head around it's implications, so I could not tell you.
Not really, it's got nothing to do with ahk, as far as this behaviour is concerned, it's just how the keyboard works when numlock is on. i.e. You can test it in notepad or the quick reply section of this forum, with a few spaces in it so you can see the cursor move. Exit/Suspend all scripts, Put numlock on, push shift and a numpad key, it will do it's numlock off action. AHK is just receiving what is produced.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Google [Bot], RandomBoy, scriptor2016 and 350 guests