---
I particularly like Microsoft's system for inputting commonly accented/international characters (and other useful symbols) in Word/Outlook/etc., but of course, they only work in Office products. AHK to the rescue then (though I have to imagine someone has written this before).
The shortcuts implemented are here: https support.office.com /en-us/article/keyboard-shortcuts-for-international-characters-108fa0c1-fb8e-4aae-9db1-d60407d13c35 Broken Link for safety
And I added a few from here: https support.office.com /en-us/article/Keyboard-shortcuts-for-Microsoft-Word-on-Windows-95EF89DD-7142-4B50-AFB2-F762F663CEB2 Broken Link for safety
Hope someone else finds it useful, or can improve/extend it.
Code: Select all
; -------- Autohotkey script: Use Microsoft Office keyboard shortcuts for international characters in any context
; -------- For list of these shortcuts, visit https support.office.com /en-us/article/keyboard-shortcuts-for-international-characters-108fa0c1-fb8e-4aae-9db1-d60407d13c35 Broken Link for safety
; -------- Also does the following character shortcuts: em dash, en dash, elipsis, copyright, trademark, registered trademark
; -------- These are described here: https support.office.com /en-us/article/Keyboard-shortcuts-for-Microsoft-Word-on-Windows-95EF89DD-7142-4B50-AFB2-F762F663CEB2 Broken Link for safety
; --------
; -------- (c) 2020 VictoryRice: no rights reserved :-)
; -------- Thanks to user Laszlo https://autohotkey.com/board/topic/14014-help-with-script-to-emulate-apple-keyboard-syle-accent-marks/
;
; Note 1: For the accents/diacritics, you have 2 seconds after pressing the dead key to press the letter you want accented.
; Note 2: A limitation of this script is that after pressing the dead key, pressing an accent-able letter within 2 seconds
; will accent the character *even if you've pressed another key in the meantime*. (Unless that other key is also
; accent-able by a different dead key monitored by this script.) I couldn't think of an efficient way to solve this,
; but given that this would rarely, if ever, happen, I didn't try very hard either ;-).
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
#Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
#UseHook
; ---- Workaround for Ctrl-: dead key (control-colon)
; ---- Must be at top of script
; ---- alternatively could have mapped to ^+; on standard US keyboard layouts
; ---- other layouts may not require Shift for the colon key though
Hotkey, ^:, DoNothing
Return
DoNothing:
Return
; ---- Set up the other dead keys to do nothing
^`::Return
^'::Return
^^::Return
^~::Return
;^+;::Return
^@::Return
^&::Return
^,::Return
^/::Return
; ---- Set up the accent-able keys that will work with at least one of the dead key combos above
a::f()
c::f()
d::f()
e::f()
i::f()
n::f()
o::f()
s::f()
u::f()
y::f()
+a::f()
+c::f()
+d::f()
+e::f()
+i::f()
+n::f()
+o::f()
+u::f()
+y::f()
; ---- Set up the shortcuts that don't require a dead key to be pressed first
; ------- Inverted punctuation
!^?::
SendInput ¿
Return
!^!::
SendInput ¡
Return
; ------- Dashes etc.
^NumpadSub::
SendInput – ; en-dash
Return
^!NumpadSub::
SendInput — ; em-dash
Return
^!.::
SendInput … ; elipsis
Return
; ------- Symbols
^!c::
SendInput © ; copyright
Return
^!r::
SendInput ® ; registered trademark
Return
^!t::
SendInput ™ ; trademark
Return
^!e::
SendInput € ; Euro
Return
; --------------- The logic combining dead keys with accent-able keys
f() {
kts = % A_ThisHotkey ; kts = Key To Send
; ------- Accent Grave -------
if (A_PriorHotkey = "^``" && A_TimeSincePriorHotkey < 2000) {
if (A_ThisHotkey = "a")
kts = à
else if (A_ThisHotkey = "e")
kts = è
else if (A_ThisHotkey = "e")
kts = è
else if (A_ThisHotkey = "i")
kts = ì
else if (A_ThisHotkey = "o")
kts = ò
else if (A_ThisHotkey = "u")
kts = ù
else if (A_ThisHotkey = "+a")
kts = À
else if (A_ThisHotkey = "+e")
kts = È
else if (A_ThisHotkey = "+i")
kts = Ì
else if (A_ThisHotkey = "+o")
kts = Ò
else if (A_ThisHotkey = "+u")
kts = Ù
}
; ------- Accent Acute -------
else if (A_PriorHotkey = "^'" && A_TimeSincePriorHotkey < 2000) {
if (A_ThisHotkey = "a")
kts = á
else if (A_ThisHotkey = "e")
kts = é
else if (A_ThisHotkey = "i")
kts = í
else if (A_ThisHotkey = "o")
kts = ó
else if (A_ThisHotkey = "u")
kts = ú
else if (A_ThisHotkey = "y")
kts = ý
else if (A_ThisHotkey = "+a")
kts = Á
else if (A_ThisHotkey = "+e")
kts = É
else if (A_ThisHotkey = "+i")
kts = Í
else if (A_ThisHotkey = "+o")
kts = Ó
else if (A_ThisHotkey = "+u")
kts = Ú
else if (A_ThisHotkey = "+y")
kts = Ý
; ------- Eth -------
else if (A_ThisHotkey = "d")
kts = ð
else if (A_ThisHotkey = "+d")
kts = Ð
}
; ------- Circumflex -------
if (A_PriorHotkey = "^^" && A_TimeSincePriorHotkey < 2000) {
if (A_ThisHotkey = "a")
kts = â
else if (A_ThisHotkey = "e")
kts = ê
else if (A_ThisHotkey = "e")
kts = è
else if (A_ThisHotkey = "i")
kts = î
else if (A_ThisHotkey = "o")
kts = ô
else if (A_ThisHotkey = "u")
kts = û
else if (A_ThisHotkey = "+a")
kts = Â
else if (A_ThisHotkey = "+e")
kts = Ê
else if (A_ThisHotkey = "+i")
kts = Î
else if (A_ThisHotkey = "+o")
kts = Ô
else if (A_ThisHotkey = "+u")
kts = Û
}
; ------- Tilde -------
if (A_PriorHotkey = "^~" && A_TimeSincePriorHotkey < 2000) {
if (A_ThisHotkey = "a")
kts = ã
else if (A_ThisHotkey = "n")
kts = ñ
else if (A_ThisHotkey = "o")
kts = õ
else if (A_ThisHotkey = "+a")
kts = Ã
else if (A_ThisHotkey = "+n")
kts = Ñ
else if (A_ThisHotkey = "+o")
kts = Õ
}
; ------- Umlaut/Diaeresis -------
else if (A_PriorHotkey = "^:" && A_TimeSincePriorHotkey < 2000) {
if (A_ThisHotkey = "a")
kts = ä
else if (A_ThisHotkey = "e")
kts = ë
else if (A_ThisHotkey = "i")
kts = ï
else if (A_ThisHotkey = "o")
kts = ö
else if (A_ThisHotkey = "u")
kts = ü
else if (A_ThisHotkey = "y")
kts = ÿ
else if (A_ThisHotkey = "+a")
kts = Ä
else if (A_ThisHotkey = "+e")
kts = Ë
else if (A_ThisHotkey = "+i")
kts = Ï
else if (A_ThisHotkey = "+o")
kts = Ö
else if (A_ThisHotkey = "+u")
kts = Ü
else if (A_ThisHotkey = "+y")
kts = Ÿ
}
; ------- Ring -------
else if (A_PriorHotkey = "^@" && A_TimeSincePriorHotkey < 2000) {
if (A_ThisHotkey = "a")
kts = å
else if (A_ThisHotkey = "+a")
kts = Å
}
; ------- Ligature -------
else if (A_PriorHotkey = "^&" && A_TimeSincePriorHotkey < 2000) {
if (A_ThisHotkey = "a")
kts = æ
else if (A_ThisHotkey = "+a")
kts = Æ
else if (A_ThisHotkey = "o")
kts = œ
else if (A_ThisHotkey = "+O")
kts = Œ
else if (A_ThisHotkey = "s")
kts = ß
}
; ------- Cedilla -------
else if (A_PriorHotkey = "^," && A_TimeSincePriorHotkey < 2000) {
if (A_ThisHotkey = "c")
kts = ç
else if (A_ThisHotkey = "+c")
kts = Ç
}
; ------- Slashed O -------
else if (A_PriorHotkey = "^/" && A_TimeSincePriorHotkey < 2000) {
if (A_ThisHotkey = "o")
kts = ø
else if (A_ThisHotkey = "+o")
kts = Ø
}
; ------- Correctly handle CAPS LOCK with and without Shift held -------
if GetKeyState("Capslock", "T") {
if pos := InStr(kts, "+") {
kts := SubStr(kts,pos+1)
}
else {
kts := "+" . kts
}
}
SendInput % kts
}