Remap complete keypad on Laptop without it. With toggle and press button function Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
comb
Posts: 4
Joined: 07 May 2021, 16:11

Remap complete keypad on Laptop without it. With toggle and press button function

07 May 2021, 17:03

Hi,

I'm quite new on this. I would really appreciate if some of you great minds could help me with these..

The problem: I have a laptop without a keypad, and would like to remap the keyboard letter to the keypad numbers.

I'm looking to achieve this 2 features.

1. When I press and hold the Fn button + "J", I get a "4" as result. But I've been looking for the Fn key to do it, and I think it's not possible. I've checked the documentation about the Special keys "mysterykey" section, without success.. so for alternative I use the Left Alt key. If someone knows how to get it working with the Fn, that would be great :)
2. When I press the "Pause" button, to act like a NumLock ON, so after press and release it, and then I press "J" I would get "4" as result and when I press again the "Pause" and after that the "J" I would get as a result "J"

For now I have this and it works:

1. Works with the Left Alt key pressed. Found no way to get it work with the Fn key. :(

Code: Select all

LAlt & SPACE::Send, {Numpad0}
LAlt & M::Send, {Numpad1}
LAlt & ,::Send, {Numpad2}
LAlt & .::Send, {Numpad3}
LAlt & J::Send, {Numpad4}
LAlt & K::Send, {Numpad5}
LAlt & L::Send, {Numpad6}
LAlt & U::Send, {Numpad7}
LAlt & I::Send, {Numpad8}
LAlt & O::Send, {Numpad9}
LAlt & -::send, {NumpadDot}
LAlt & 7::send, {NumpadDiv}
LAlt & 8::send, `%
LAlt & 9::send, {NumpadMult}
LAlt & 0::send, =
LAlt & P::send, {NumpadSub}
LAlt & sc027::send, {NumpadAdd}
return
2. I've been able to achieve this point, with the CapsLock. But I would like to maintain that function in its original state, so it would be great if I could use the "Pause" key to toggle that. Personally I never use the "Pause" key, so that would be as give that button some action in his life :D

Code: Select all

#If, GetKeyState("CapsLock","T")

SPACE::Send, {Numpad0}
M::Send, {Numpad1}
,::Send, {Numpad2}
.::Send, {Numpad3}
J::Send, {Numpad4}
K::Send, {Numpad5}
L::Send, {Numpad6}
U::Send, {Numpad7}
I::Send, {Numpad8}
O::Send, {Numpad9}
-::send, {NumpadDot}
7::send, {NumpadDiv}
8::send, `%
9::send, {NumpadMult}
0::send, =
P::send, {NumpadSub}
sc027::send, {NumpadAdd}
return

How can I combine this two codes in one script? Separately they work, in two differente scripts, but it would be great to have all, wrapped in one script.

BTW I've been looking around, and the possibilities of the AHK are amazing! Great program!

Thanks a lot in advance for any hint or help :)
Rohwedder
Posts: 7624
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Remap complete keypad on Laptop without it. With toggle and press button function

08 May 2021, 05:03

Hallo,
try (not fully tested):

Code: Select all

#If GetKeyState("Pause","T") Or GetKeyState("LAlt","P")
;on/off with Pause or LAlt held
*SPACE::Send, {Numpad0}
*m::Send, {Numpad1}
*,::Send, {Numpad2}
*.::Send, {Numpad3}
*j::Send, {Numpad4}
*k::Send, {Numpad5}
*l::Send, {Numpad6}
*u::Send, {Numpad7}
*i::Send, {Numpad8}
*o::Send, {Numpad9}
*-::send, {NumpadDot}
*7::send, {NumpadDiv}
*8::send, `%
*9::send, {NumpadMult}
*0::send, =
*p::send, {NumpadSub}
*sc027::send, {NumpadAdd}
#If
comb
Posts: 4
Joined: 07 May 2021, 16:11

Re: Remap complete keypad on Laptop without it. With toggle and press button function

08 May 2021, 15:53

Vielen dank Rohwedder!!! Du bist der beste!

Thanks a lot Rohwedder! You're the man! Worked like a charm! :superhappy: :superhappy:

For someone else who would like to have this same setup, I added a new line to it for the backspace, because when pressing the LAlt + Backspace acts like a Ctrl + Z, so I had to release de LAlt to be able the backspace my numbers, so with this, still pressing the LAlt I'm able to use the normal Backspace function and clear my wrong typed numbers.

Code: Select all

If GetKeyState("Pause","T") Or GetKeyState("LAlt","P")
;on/off with Pause or LAlt held
*SPACE::Send, {Numpad0}
*m::Send, {Numpad1}
*,::Send, {Numpad2}
*.::Send, {Numpad3}
*j::Send, {Numpad4}
*k::Send, {Numpad5}
*l::Send, {Numpad6}
*u::Send, {Numpad7}
*i::Send, {Numpad8}
*o::Send, {Numpad9}
*-::send, {NumpadDot}
*7::send, {NumpadDiv}
*8::send, `%
*9::send, {NumpadMult}
*0::send, =
*p::send, {NumpadSub}
*sc027::send, {NumpadAdd}
*sc028::send, {NumpadAdd}
*Backspace::Send, {BackSpace}
#If


A few doubts... is there a way that once the "Pause" is activated, when I press the LAlt key instead of giving me the number it gives me back the letters. So If I'm in the "keypad" mode I can press quickly de LAlt + J, to get back the "J". It's not that important but would be great.

And do you know if there is a good way to leave visual information, that the "Pause" is in "On" mode, as there is no "Led" on that button like the CapsLock, I don't know if it's activated or not. Maybe with a fixed MsgBox? :roll:

Anyway this two points aren't that important as the script you gave me!! Finally get back the keypad function on this laptop!

Thanks again :)
Rohwedder
Posts: 7624
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Remap complete keypad on Laptop without it. With toggle and press button function  Topic is solved

09 May 2021, 04:01

Then perhaps:

Code: Select all

CoordMode, ToolTip, Screen
SetTimer, KeypadMode, 200
KeypadMode:
ToolTip,% KeypadMode()?"Keypad Mode":"", 0, 0, 8
Return ; 0,0 = upper left corner of the monitor 
#If GetKeyState("Pause","T")
LAlt::Return ; LAlt loses its normal function!
#If KeypadMode() ; on/off with Pause xor LAlt held
*SPACE::Send, {Numpad0}
*m::Send, {Numpad1}
*,::Send, {Numpad2}
*.::Send, {Numpad3}
*j::Send, {Numpad4}
*k::Send, {Numpad5}
*l::Send, {Numpad6}
*u::Send, {Numpad7}
*i::Send, {Numpad8}
*o::Send, {Numpad9}
*-::send, {NumpadDot}
*7::send, {NumpadDiv}
*8::send, `%
*9::send, {NumpadMult}
*0::send, =
*p::send, {NumpadSub}
*sc027::send, {NumpadAdd}
*sc028::send, {NumpadAdd}
*Backspace::Send, {BackSpace}
#If
KeypadMode()
{
	Return, GetKeyState("Pause","T") ^ GetKeyState("LAlt","P")
}
Important! As soon as the Pause-Toogle is activated, the LAlt key becomes a "numpad deactivator", i.e. it loses its normal function
comb
Posts: 4
Joined: 07 May 2021, 16:11

Re: Remap complete keypad on Laptop without it. With toggle and press button function

09 May 2021, 06:11

Amazing!! :superhappy: Works like a charm! You are now my hero Rohwedder :D . You give my laptop a second life!.

Hope this can help more people in the future, because I've been looking for something like this in internet and didn't find it anywhere.

Vielen dank nochmals!!
comb
Posts: 4
Joined: 07 May 2021, 16:11

Re: Remap complete keypad on Laptop without it. With toggle and press button function

09 May 2021, 06:29

Was testing it, and works perfect, only that I have other programs that I still need to give the Alt key his normal function, so I will use your previous code + with the CoordMode, Tooltip.

I will sacrifice the option to not be able to toggle back to keyboard letters once the "Pause" button has activated the Keypad Mode, because I will use more the Alt key with his normal function. Thought it would be possible to have still the normal function from the Alt key plus only to deactivate the keypad "letters". But it's perfect so. Does what I was looking for! This was an extra feature..

Thanks again!

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: drani, Google [Bot], montie, Nerafius and 237 guests