Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
AutoHotKey stuff
#UseHook
!VKC0SC029::Return ; grave -> the grave ` accent gave some probs, used the virtualkey + scancode instead
!e::Return ; acute
!i::Return ; circumflex
!t::Return ; tilde
!u::Return ; umlaut
; 1 2 3 4 5 6 7 8 9 1
; 0
; r g G a A c C t T u U
*a::diacritic("a","à,À,á,Á,â,Â,ã,Ã,ä,Ä")
*e::diacritic("e","è,È,é,É,ê,Ê,e,E,ë,Ë")
*i::diacritic("i","ì,Ì,í,Í,î,Î,i,I,ï,Ï")
*o::diacritic("o","ò,Ò,ó,Ó,ô,Ô,õ,Õ,ö,Ö")
*u::diacritic("u","ù,Ù,ú,Ú,û,Û,u,U,ü,Ü")
*n::diacritic("n","n,N,n,N,n,N,ñ,Ñ,n,N")
*y::diacritic("y","y,Y,y,Y,y,Y,y,Y,ÿ,Ÿ")
diacritic(regular,accentedCharacters) {
StringSplit, char, accentedCharacters, `,
graveOption := char1
graveShiftOption := char2
acuteOption := char3
acuteShiftOption := char4
circumflexOption := char5
circumflexShiftOption := char6
tildeOption := char7
tildeShiftOption := char8
umlautOption := char9
umlautShiftOption := char10
if (A_PriorHotKey = "!VKC0SC029" && A_TimeSincePriorHotkey < 2000) {
if (GetKeyState("Shift")) {
SendInput % graveShiftOption
} else {
SendInput % graveOption
}
} else if (A_PriorHotKey = "!e" && A_TimeSincePriorHotkey < 2000) {
if (GetKeyState("Shift")) {
SendInput % acuteShiftOption
} else {
SendInput % acuteOption
}
} else if (A_PriorHotKey = "!i" && A_TimeSincePriorHotkey < 2000) {
if (GetKeyState("Shift")) {
SendInput % circumflexShiftOption
} else {
SendInput % circumflexOption
}
} else if (A_PriorHotKey = "!t" && A_TimeSincePriorHotkey < 2000) {
if (GetKeyState("Shift")) {
SendInput % tildeShiftOption
} else {
SendInput % tildeOption
}
} else if (A_PriorHotKey = "!u" && A_TimeSincePriorHotkey < 2000) {
if (GetKeyState("Shift")) {
SendInput % umlautShiftOption
} else {
SendInput % umlautOption
}
} else {
if (GetKeyState("Shift") or GetKeyState("Capslock","T")) {
SendInput % "+" regular
} else {
SendInput % regular
}
}
}
;
; Alt + Shift + key
;
*!1::altShift("¡","/")
*!2::altShift("","")
*!3::altShift("£","")
*!4::altShift("¢","")
*!5::altShift("8","fi")
*!6::altShift("§","fl")
*!7::altShift("","")
*!8::altShift("","°")
*!9::altShift("ª","·")
*!0::altShift("º","")
*!a::altShift("å","Å")
*!b::altShift("","ı")
*!c::altShift("ç","Ç")
*!d::altShift("","Î")
*!e::altShift("´","")
*!f::altShift("ƒ","Ï")
*!g::altShift("©","Ì")
*!h::altShift("˙","Ó")
*!i::altShift("^","È")
*!j::altShift("Δ","Ô")
*!k::altShift("°","Apple")
*!l::altShift("¬","Ò")
*!m::altShift("µ","˜")
*!n::altShift("~","ˆ")
*!o::altShift("ø","Ø")
*!p::altShift("π","Π")
*!q::altShift("œ","Œ")
*!r::altShift("®","Â")
*!s::altShift("ß","Í")
;*!t::altShift("†","Ê")
*!u::altShift("¨","Ë")
*!v::altShift("v","")
*!w::altShift("ε","")
*!x::altShift("","Ù")
*!y::altShift("¥","Á")
*!z::altShift("ω","Û")
*!-::altShift("","")
*!=::altShift("!=","±")
*![::altShift("","")
*!]::altShift("","")
*!`;::altShift("","Ú")
*!'::altShift("æ","Æ")
*!\::altShift("«","»")
*!,::altShift("<=","¯")
*!.::altShift(">=","˘")
*!/::altShift("÷","¿")
altShift(accented,accentedShift) {
if (!GetKeyState("Shift")) {
SendInput % accented
} else {
SendInput % accentedShift
}
}
; Fix for some CTRL + stuff that may not work
; This must be done for each character with diacritics as defined near the top of the script
^a::
SetKeyDelay -1
Send ^a
return
^+a::
SetKeyDelay -1
Send ^+a
return
^e::
SetKeyDelay -1
Send ^e
return
^+e::
SetKeyDelay -1
Send ^+e
return
^i::
SetKeyDelay -1
Send ^i
return
^+i::
SetKeyDelay -1
Send ^+i
return
^o::
SetKeyDelay -1
Send ^o
return
^+o::
SetKeyDelay -1
Send ^+o
return
^u::
SetKeyDelay -1
Send ^u
return
^+u::
SetKeyDelay -1
Send ^+u
return
^n::
SetKeyDelay -1
Send ^n
return
^+n::
SetKeyDelay -1
Send ^+n
return
^y::
SetKeyDelay -1
Send ^y
return
^+y::
SetKeyDelay -1
Send ^+y
return
!-::–
!+-::—
@patik

This comment has been minimized.

Copy link
Owner Author

@patik patik commented Nov 8, 2016

This is a modification of the gist found in this Aaron Gustafson blog post.

Changes:

  1. Replace literal strings like "delta" and "integral" with the actual characters
    • Exception: "Apple" remains because there's no Apple logo in Windows
  2. Fix for control-key shortcuts (control-N, control-shift-N, etc)
@colindean

This comment has been minimized.

Copy link

@colindean colindean commented Dec 10, 2020

I'm having some trouble with the scan code on Line 2. Apparently, newer versions of AHK disable using scancodes with Return, quoth here. Have you worked around this in another way?

@colindean

This comment has been minimized.

Copy link

@colindean colindean commented Dec 10, 2020

Looks like a commenter on the original post found it: sc029

@colindean

This comment has been minimized.

Copy link

@colindean colindean commented Dec 10, 2020

I'm also getting ã Ã in front of alI shortcuts I try to type?

Typing into VScode in a text file set to UTF-8:

Shift+Alt+2 = â„¢
Shift+Alt+3 = ‹
Alt + 2 = €
Alt + 3 = £

Ideas?

@patik

This comment has been minimized.

Copy link
Owner Author

@patik patik commented Dec 10, 2020

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.