Implementing alt codes on a keyboard without a numpad

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
607
Posts: 4
Joined: 26 Sep 2021, 10:08

Implementing alt codes on a keyboard without a numpad

Post by 607 » 11 Nov 2021, 04:51

Hi, it's me again!

I have some experience with AutoHotkey, but haven't got too deep into it. I wonder if I could use it to simulate a num pad to type alt codes.
I recently bought a laptop that does not have a real num pad but also not a virtual num pad, for some reason. With this keyboard it is not at all possible to type alt codes. Can AutoHotkey implement a virtual num pad? For example being able to type fn + alt + M, K, L, L to send alt code 0233 (becoming é). I've googled for this and also searched this forum, but couldn't find the question asked, to my surprise. Let me know if I looked over it!

User avatar
mikeyww
Posts: 26931
Joined: 09 Sep 2014, 18:38

Re: Implementing alt codes on a keyboard without a numpad

Post by mikeyww » 11 Nov 2021, 08:02

Code: Select all

char := {e: "é", x: "y"}
!m::
Input, key, L1
Send % char.HasKey(key) ? char[key] : key
Return
Hotstrings are also a good solution.

Code: Select all

:?*:eee::é

607
Posts: 4
Joined: 26 Sep 2021, 10:08

Re: Implementing alt codes on a keyboard without a numpad

Post by 607 » 13 Nov 2021, 08:51

mikeyww wrote:
11 Nov 2021, 08:02

Code: Select all

char := {e: "é", x: "y"}
!m::
Input, key, L1
Send % char.HasKey(key) ? char[key] : key
Return
Hotstrings are also a good solution.

Code: Select all

:?*:eee::é
It seems to me that your solution concerns specific characters, and doesn't even use the alt codes. I don't think it is relevant to my problem. Although it could be good as a temporary workaround (for accents however, there is a workaround built in-to Windows: add an international keyboard, press ctrl + shift to switch, type ', ", or `, and type the letter (for example ' + e becomes é), then press ctrl + shift to switch back to the regular keyboard).

User avatar
mikeyww
Posts: 26931
Joined: 09 Sep 2014, 18:38

Re: Implementing alt codes on a keyboard without a numpad

Post by mikeyww » 13 Nov 2021, 09:09

Code: Select all

#!m:: ; WIN-ALT-M = Send ASCII character
SoundBeep, 1700
Input, key, L3
str := key
For letter, number in {j: 1, k: 2, l: 3, u: 4, i: 5, o: 6, m: 0}
 str := StrReplace(str, letter, number)
Send % str ~= "^\d+$" ? Format("{ASC {:04}}", str) : key
Return

607
Posts: 4
Joined: 26 Sep 2021, 10:08

Re: Implementing alt codes on a keyboard without a numpad

Post by 607 » 09 Dec 2021, 07:19

Sorry for the very late reply...
mikeyww wrote:
13 Nov 2021, 09:09

Code: Select all

#!m:: ; WIN-ALT-M = Send ASCII character
SoundBeep, 1700
Input, key, L3
str := key
For letter, number in {j: 1, k: 2, l: 3, u: 4, i: 5, o: 6, m: 0}
 str := StrReplace(str, letter, number)
Send % str ~= "^\d+$" ? Format("{ASC {:04}}", str) : key
Return
Thank you, that works! It only supports the four character ALT codes, and not the one to three character ones. This should be very useful, in any case! Maybe I'll try if I can make it support any length by using EndKeys over the holidays.

User avatar
mikeyww
Posts: 26931
Joined: 09 Sep 2014, 18:38

Re: Implementing alt codes on a keyboard without a numpad

Post by mikeyww » 09 Dec 2021, 07:33

Sure, you can do this kind of thing.

Code: Select all

#!m:: ; WIN-ALT-M = Send ASCII character
SoundBeep, 1700
Input, key, L4, {Enter}
str := key
For letter, number in {j: 1, k: 2, l: 3, u: 4, i: 5, o: 6, m: 0}
 str := StrReplace(str, letter, number)
Send % str ~= "^\d+$" ? Format("{ASC {:0" StrLen(str) "}}", str) : key
Return

User avatar
12Centuries
Posts: 5
Joined: 26 Aug 2021, 16:07

Re: Implementing alt codes on a keyboard without a numpad

Post by 12Centuries » 08 Feb 2023, 14:23

Another great approach to this is here: viewtopic.php?p=331322#p331322

Allows you to use the alt key and the top-row numbers to enter any ascii code.

Post Reply

Return to “Ask for Help (v1)”