The following script works great with the main keyboard number keys but InputHook() fails on the numeric keypad.
It allows you to enter hex Unicode ( eg 221e and so on ) values in order to insert special characters.
Instructions are in the comment header and it will display all keystrokes entered as a tooltip.
I did try adding {Numeric7} etc to KeyOpt but to no avail.
A second problem is that InputHook() fails to recognize key-up codes as input termination characters.
I tried InputHook("L5 T9 M","{LAlt up}") and even though it dispatches OnKeyUp, it fails to actually stop and so I had to implement the rather silly work-around in my code below.
Despite these problems, the program works great, much better than the crap which microsoft has spewed upon the masses (This program works exactly the same way but it ACTUALLY works reliably and doesn't require a registry key). It's a mind-numbing thought that MS has not provided any reasonable way to enter unicode characters into Windows. I often do this many times per day, so AutoHotKey and the program below and is a true godsend.
Code: Select all
#Requires AutoHotkey v2.0
; https://www.autohotkey.com/
; Instructions:
; Hold down ALT key
; Punch + key
; Type a 1~5 digit hex code, eg: f7
; Release ALT key
; Hit Esc key at any point to cancel out
; Times out after 9s to prevent confusion
; Put this script into: shell:startup
; Or better into: shell:common startup
!NumpadAdd::
!+::
{
ih := InputHook("L5 T9 M","{Space}{Enter}{Escape}")
ih.VisibleNonText := False
ih.KeyOpt("{All}", "+I -N")
ih.KeyOpt("1234567890abcdef", "-I")
ih.KeyOpt("{LAlt}{RAlt}", "+N")
ih.OnKeyUp := KeyUp
ih.Start()
ih.Wait()
if (ih.EndReason = "Timeout" or ih.EndKey = "Escape")
return
Send "{U+" ih.Input "}"
ToolTip "{U+" ih.Input "}"
SetTimer () => ToolTip(), -3000
}
KeyUp(ih, vk, sc)
{
ih.Stop()
;MsgBox GetKeyName(Format("vk{:x}sc{:x}", vk, sc)) " vk" vk " sc" sc
}