Numpad Remap - 00 key causing many issues

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
BBL-2-MWH
Posts: 6
Joined: 30 Nov 2018, 23:48

Numpad Remap - 00 key causing many issues

01 Dec 2018, 01:24

Just purchased my first mechanical keyboard and I'm attempting to remap the number pad in a way that I can use all 0-9 num keys + the nav keys without having to toggle back and forth with numlock (image below), but I'm running into 2 problems:

Image

I. That pesky 00 key (which has the same scan code as the 0 key) cannot be fully differentiated from the regular numpad zero. My script/coding skills are super weak, so I used some guy's genius code to turn the 00 into the down key (source and code logic below), but I can't write code for the left key now because it's referring to the same 0 as the 00 key.

II. I spend most of day in MS Excel, so I'm constantly using Excel's built in short-cuts to navigate spread sheets (ex. ctrl+left, ctrl+shift+down), but none of the remapped nav-keys work when I try to use them in conjunction with the other ctrl, shift, etc. keys.

Desperate here.... if anyone could help, I would really appreciate it. Happy to return the favor if I can.

Current script for 00 + link to source
http://dann.com.br/keyboard-cm-quick-fi ... g-numlock/
#MaxThreadsPerHotkey 5
$Numpad0::
#MaxThreadsPerHotkey 1
SetBatchLines, 100
DelayBetweenKeys = 30
if A_PriorHotkey = %A_ThisHotkey%
{
if A_TimeSincePriorHotkey < %DelayBetweenKeys%
{
if Numpad0Count =
Numpad0Count = 2
else if Numpad0Count = 0
Numpad0Count = 2
else
{
Numpad0Count = 0
Send, =
}
CalledReentrantly = y
Send, {NumpadDown}
return
}
}
Numpad0Count = 0
CalledReentrantly = n
Sleep, %DelayBetweenKeys%
if CalledReentrantly = y
{
CalledReentrantly = n
return
}
Send, {Numpad0}
Return
User avatar
Nextron
Posts: 1391
Joined: 01 Oct 2013, 08:23
Location: Netherlands OS: Win10 AHK: Unicode x32

Re: Numpad Remap - 00 key causing many issues

01 Dec 2018, 13:56

Nice graphical explanation!

Even though you probably can get some differentiation between 0 and 00, it will introduce a delay, so for something like gaming or holding down a key it won't be ideal. That the hotkeys/remappings stop working when you introduce modifier keys like Ctrl/Shift is twofold: AHK ignores those unless you make them a specific hotkey or you use a wildcard like: *Numpad0::. The second is that numpad keys change their virtual key name when toggling numlock or holding shift, e.g. Numpad9 becomes NumpadPgUp. So that needs to be taken into account.

Run the following script, press and hold the 00 for a second, press F5 and copy the output here, to show how that key behaves.

Code: Select all

#Persistent
#InstallKeybdHook
KeyHistory
Next time, put your code in [/c] tags for readibility

On second thought, when numlock is off, and you can use the arrow keys, does holding shift change the function back to numbers? That would be useless during gaming. If the arrow function remains, it would be a lot easier to just set up the remappings with NumLock off, since there's no 00 anymore, asuming 1 and 3 still work.
User avatar
BBL-2-MWH
Posts: 6
Joined: 30 Nov 2018, 23:48

Re: Numpad Remap - 00 key causing many issues

01 Dec 2018, 22:21

Great info. Thanks Nextron! Follow ups below.

1. I agree the delay is not ideal, but I can live with it if this is the only way
2. Your script returned:

Code: Select all

VK  SC	Type	Up/Dn	Elapsed	Key		Window
-------------------------------------------------------------------------------------------------------------
28  050	i	d	0.00	NumpadDown     	
28  050	i	u	0.00	NumpadDown     	
60  052	 	u	0.01	Numpad0        	
60  052	 	d	0.14	Numpad0        	
60  052	 	u	0.00	Numpad0        	
60  052	 	d	0.01	Numpad0        	
28  050	i	d	0.00	NumpadDown     	
28  050	i	u	0.00	NumpadDown     	
60  052	 	u	0.00	Numpad0        	
60  052	 	d	0.16	Numpad0        	
60  052	 	u	0.00	Numpad0        	
60  052	 	d	0.02	Numpad0        	
28  050	i	d	0.00	NumpadDown     	
28  050	i	u	0.00	NumpadDown     	
60  052	 	u	0.00	Numpad0        	
60  052	 	d	0.16	Numpad0        	
60  052	 	u	0.00	Numpad0        	
60  052	 	d	0.01	Numpad0        	
28  050	i	d	0.00	NumpadDown     	
28  050	i	u	0.00	NumpadDown     	
60  052	 	u	0.00	Numpad0        	
60  052	 	d	0.14	Numpad0        	
60  052	 	u	0.01	Numpad0        	
60  052	 	d	0.00	Numpad0        	
28  050	i	d	0.00	NumpadDown     	
28  050	i	u	0.00	NumpadDown     	
60  052	 	u	0.02	Numpad0        	
60  052	 	d	0.14	Numpad0        	
60  052	 	u	0.02	Numpad0        	
60  052	 	d	0.00	Numpad0        	
28  050	i	d	0.00	NumpadDown     	
28  050	i	u	0.00	NumpadDown     	
60  052	 	u	0.02	Numpad0        	
60  052	 	d	0.14	Numpad0        	
60  052	 	u	0.00	Numpad0        	
60  052	 	d	0.02	Numpad0        	
28  050	i	d	0.00	NumpadDown     	
28  050	i	u	0.00	NumpadDown     	
60  052	 	u	0.00	Numpad0        	
74  03F	 	d	5.65	F5
3. Using shift+arrows with Numlock off doesn't change the function back to numbers. The arrows still work and they work with Excel's built-in short-cuts, however, the 1 and 3 don't work with Numlock off. I agree this would be easier with Numlock off; is it possible to script those keys with the Numlock off?
User avatar
Nextron
Posts: 1391
Joined: 01 Oct 2013, 08:23
Location: Netherlands OS: Win10 AHK: Unicode x32

Re: Numpad Remap - 00 key causing many issues

02 Dec 2018, 07:44

2: Could you redo this but with the other script not running? While you're at it, also press the Numpad1 and Numpad3 while NumLock is off.
3: It promising Shift doesn't interfere withthe arrows, let's find out if it's doable.
User avatar
Maestr0
Posts: 136
Joined: 05 Dec 2013, 17:43

Re: Numpad Remap - 00 key causing many issues

02 Dec 2018, 08:43

I'd suggest doing all the numpad keys from 7 on down, one press each, then you can best see the difference between the 0 and 00 keys
User avatar
BBL-2-MWH
Posts: 6
Joined: 30 Nov 2018, 23:48

Re: Numpad Remap - 00 key causing many issues

02 Dec 2018, 15:38

It's my understanding the 00 is just a double tap of 0 and not really a separate key (as 0 and 00 both share the same scan code). With numlock off, the 1 and 3 don't register as key presses, and don't have a scan code. Results below.

00 (numlock on) Returned:

Code: Select all

VK  SC	Type	Up/Dn	Elapsed	Key		Window
-------------------------------------------------------------------------------------------------------------
60  052	 	d	11.48	Numpad0        	C:\Users\212286\Desktop\00 test.ahk - AutoHotkey v1.1.30.01
60  052	 	u	0.02	Numpad0        	
60  052	 	d	0.00	Numpad0        	
60  052	 	u	0.01	Numpad0        	
60  052	 	d	0.14	Numpad0        	
60  052	 	u	0.00	Numpad0        	
60  052	 	d	0.01	Numpad0        	
60  052	 	u	0.02	Numpad0        	
60  052	 	d	0.14	Numpad0        	
60  052	 	u	0.00	Numpad0        	
60  052	 	d	0.02	Numpad0        	
60  052	 	u	0.00	Numpad0        	
60  052	 	d	0.16	Numpad0        	
60  052	 	u	0.00	Numpad0        	
60  052	 	d	0.02	Numpad0        	
60  052	 	u	0.00	Numpad0        	
60  052	 	d	0.14	Numpad0        	
60  052	 	u	0.02	Numpad0        	
74  03F	 	d	2.59	F5       


00 (numlock off) Returned:

Code: Select all

VK  SC	Type	Up/Dn	Elapsed	Key		Window
-------------------------------------------------------------------------------------------------------------
28  150	 	d	5.01	Down           	C:\Users\212286\Desktop\00 test.ahk - AutoHotkey v1.1.30.01
28  150	 	d	0.50	Down           	
28  150	 	d	0.05	Down           	
28  150	 	d	0.03	Down           	
28  150	 	d	0.03	Down           	
28  150	 	d	0.03	Down           	
28  150	 	d	0.03	Down           	
28  150	 	d	0.03	Down           	
28  150	 	d	0.03	Down           	
28  150	 	d	0.03	Down           	
28  150	 	d	0.03	Down           	
28  150	 	d	0.03	Down           	
28  150	 	u	0.01	Down           	
74  03F	 	d	1.67	F5 

1 (numlock off) Returned

Code: Select all

VK  SC	Type	Up/Dn	Elapsed	Key		Window
-------------------------------------------------------------------------------------------------------------
74  03F	 	d	11.12	F5             	C:\Users\212286\Desktop\00 test.ahk - AutoHotkey v1.1.30.01

3 (numlock off) Returned:

Code: Select all

VK  SC	Type	Up/Dn	Elapsed	Key		Window
-------------------------------------------------------------------------------------------------------------
74  03F	 	d	13.03	F5             	C:\Users\212286\Desktop\00 test.ahk - AutoHotkey v1.1.30.01
User avatar
Nextron
Posts: 1391
Joined: 01 Oct 2013, 08:23
Location: Netherlands OS: Win10 AHK: Unicode x32

Re: Numpad Remap - 00 key causing many issues

03 Dec 2018, 09:08

You need to finish up the remaining key remappings, but see if the 00 and 0 are differentiated properly.

Code: Select all

*Numpad0::
	T:=25
	T1:=A_TickCount
	If (T1-T0>T || T0=""){
		SetTimer,Send0,-%T%,On
	}Else{
		Send {Blind}{Left}
		SetTimer,Send0,Off
	}
	T0:=T1
Return
Send0:
	Send {Blind}{Down}
Return
NumpadDot::Right
Numpad2::Up
Numpad7::Numpad4
NumpadIns::Numpad4

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Joey5 and 341 guests