Skip to content

Instantly share code, notes, and snippets.

@rbika
Last active October 17, 2021 13:34
Show Gist options
  • Save rbika/111bde86fb3315eca00f841ccdedd261 to your computer and use it in GitHub Desktop.
Save rbika/111bde86fb3315eca00f841ccdedd261 to your computer and use it in GitHub Desktop.
AutoHotKey script to simulate macOS accentuation system
; macOS accentuation system
; source: https://gist.github.com/rbika/111bde86fb3315eca00f841ccdedd261
#NoEnv
SendMode Input
SetWorkingDir %A_ScriptDir%
#`::previewAccent("``")
#e::previewAccent("´")
#i::previewAccent("ˆ")
#n::previewAccent("˜")
$a::accentedLetter("a,A", "à,À,á,Á,â,Â,ã,Ã")
$e::accentedLetter("e,E", "è,È,é,É,ê,Ê,e,E")
$i::accentedLetter("i,I", "ì,Ì,í,Í,î,Î,i,I")
$o::accentedLetter("o,O", "ò,Ò,ó,Ó,ô,Ô,õ,Õ")
$u::accentedLetter("u,U", "ù,Ù,ú,Ú,û,Û,u,U")
#c::Send ç
#+c::Send Ç
; Shows accent preview and applies text selection
previewAccent(accent) {
Send % accent
Send {left}+{right}
}
; Sends the correct accented character to replace the accent preview
accentedLetter(regular, accented) {
regularArray := StrSplit(regular, ",")
accentedArray := StrSplit(accented, ",")
if (GetKeyState("Shift"))
shiftState := 1
else
shiftState := 0
if (A_PriorHotKey = "#``") {
Send % accentedArray[1 + shiftState]
} else if (A_PriorHotKey = "#e") {
Send % accentedArray[3 + shiftState]
} else if (A_PriorHotKey = "#i") {
Send % accentedArray[5 + shiftState]
} else if (A_PriorHotKey = "#n") {
Send % accentedArray[7 + shiftState]
} else {
Send % regularArray[1 + shiftState]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment