Copyright © 2023 Pandalism
14 February 2021
[
]
Common issue when typing in non-english languages is that not all the letters are easily accessible. Whilst porting over some of my utility scripts I thought I might as well publish this Autohotkey snippet which lets me use ñ, á, é, í, ó, ú and ü in a very quick and intuitive way with a British keyboard.
As previously mentioned, AHK is a rather old event driven scripting language, a little rough around the edges, and sometimes severely abused into being used for programs where maybe something else would be better. However, as the name implies it does hotkeys and hotstrings incredibly well, and it has no rival for it. On to the script!
#SingleInstance, Force
SendMode Input
SetWorkingDir, %A_ScriptDir%
; following two hotstrings will replace nhx into ñ, in caps too.
; n ñ Ñ
:C?*:nhx::
Send {U+00F1}
ToolTip, ñ
Return
:C?*:NHX::
Send {U+00D1}
ToolTip, Ñ
Return
; these hotstrings will make vowels with ' spanish accents or "
; a á Á
:C?*:a'x::
send {U+00E1}
ToolTip, á
SetTimer, RemoveToolTip, -1000
Return
:C?*:A'X::
send {U+00C1}
ToolTip, Á
SetTimer, RemoveToolTip, -1000
Return
; ...cut out for compactness ...
:C?*:u"x::
Send {U+00FC}
ToolTip, ü
SetTimer, RemoveToolTip, -1000
Return
:C?*:U"X::
Send {U+00DC}
ToolTip, Ü
SetTimer, RemoveToolTip, -1000
Return
RemoveToolTip:
ToolTip
Return
Breaking down what is happening, a hotkey subroutine takes the following format:
:C?*:U"X::
Send {U+00DC}
ToolTip, Ü
SetTimer, RemoveToolTip, -1000
Return
Where :C?*:U"X::
contains the hotstring trigger, this case being typing U “ X all together.
Autohotkey gives us some control over how to interpret the hotstring, in this case by inserting C?*
we are telling AHK to be case sensitie (C
), to trigger even as part of a word (?
) and to trigger without an ending character such as space or newline(*
).
The Send {U+00DC}
is the method used to send Ü, as a unicode character.
Tooltip, Ü
sends a tooltip, and then we use the SetTimer, RemoveToolTip, -1000
to set a timer with the RemoveToolTip
function which just clears the tooltip by setting it to an empty string. A minor detail is that for the tooltip to display correctly, the script needs to be saved using UTF-8 with BOM encoding.
Overall, pretty simple and easy to replicate but makes life just that little bit easier. I use it mainly for the ñ character, using nhx as a hotstring, and the ü for which I use u”x. Theres some trial and error in finding the right hotstring for you but it is trivial to modify the script to make it work.
Downloads for the script and a precompiled exe:
Autohotkey will always have a special place in my heart as one of the first programming/scripting languages I ever used, back in 2008 using it for gaming. It’s still one of my goto’s for simple desktop automation. I have actually uploaded some of the scripts I use up to github to show what it can be used for. At the moment most functionality is combined in one script that runs on opening:
Copyright © 2023 Pandalism