Skip to content

Instantly share code, notes, and snippets.

@moudrick
Last active March 8, 2023 14:08
Show Gist options
  • Select an option

  • Save moudrick/194cd1758fbd115291a2d377fcd082e0 to your computer and use it in GitHub Desktop.

Select an option

Save moudrick/194cd1758fbd115291a2d377fcd082e0 to your computer and use it in GitHub Desktop.
AutoHotkey 1.x script for English, Ukrainian, Crimean Tatar, Russian symbols typing
; _.ahk.lnk
; USERPROFILE
; APPDATA=USERPROFILE+\AppData\Roaming
; path: %USERPROFILE%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup
; shell:startup
; %USERPROFILE%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup
#Requires AutoHotkey <2
; http://www.script-coding.com/AutoHotkey/SingleInstance.html
#SingleInstance force
; run script as admin (reload if not as admin)
; https://stackoverflow.com/questions/41723490/how-to-build-ahk-scripts-automatically-on-startup
if not A_IsAdmin
{
Run *RunAs "%A_ScriptFullPath%"
ExitApp
}
;;; DEBUG ;;;
htkctl0 := 0x0
htkctl1 := 0x0
htkctl2 := 0x0
; Supposed indicators of keyboard language.
G_KbL_8192 := 8192 ; Suppose CRH-LAT
G_KbL_1058 := 1058 ; Suppose UKR
G_KbL_1033 := 1033 ; Suppose ENG
;MsgBox % G_KbL_8192 . " . " . G_KbL_1058 . " . " . G_KbL_1033 . " . "
AltGrRemapFor_UKR(u) {
global G_KbL_1058
if (Thread_GetKeyboardLanguage() = G_KbL_1058) {
Send %u% ; "%u%"
}
}
AltGrRemapFor_CRH(u) {
global G_KbL_8192
if (Thread_GetKeyboardLanguage() = G_KbL_8192) {
Send %u%
} ;"%u%"
}
AltGrRemapFor_ENG(u) {
global G_KbL_1033
; dd := Thread_GetKeyboardLanguage()
; MsgBox % "(" . u . "')\" . G_KbL_1033 . "--" . dd . "--"
;
if (Thread_GetKeyboardLanguage() = G_KbL_1033) {
Send %u% ; "%u%"
}
}
; CapsLock to change input language
; https://www.autohotkey.com/board/topic/65264-capslock-to-change-input-language/
; Capslock:: Send {Shift Down}{Alt Down}{Alt Up}{Shift Up}
; Capslock:: SendEvent {Shift Down}{Alt Down}{Alt Up}{Shift Up}
; Capslock:: SendEvent {Alt Down}{Shift Down}{Shift Up}{Alt Up}
Capslock:: SendEvent {LWin Down}{Space Down}{LWin Up}{Space Up}
; CapsLock into Double Shift or Ctrl-Shife multi action question
; https://www.autohotkey.com/boards/viewtopic.php?style=17&t=73958
; Autohotkey: Shift and caps lock
; https://stackoverflow.com/questions/45904966/autohotkey-shift-and-caps-lock
; SURGFACE GO
;*Capslock:: SendEvent {Alt Down}{Shift Down}
;*Capslock Up:: SendEvent {Shift Up}{Alt Up}
;Capslock:: SendEvent {Alt Down}{Shift Down}
;Capslock Up:: SendEvent {Shift Up}{Alt Up}
; *********************
; *** Kb-UA - RUS ***
; *** Ыы Ээ Ъъ Ёё ***
; *********************
; UKR -- Ыы Ээ Ъъ Ёё
<^>!+s:: AltGrRemapFor_UKR("{U+042B}") ;"Ы" ; U+042B Ы Cyrillic Capital Letter Yeru 0499
<^>!s:: AltGrRemapFor_UKR("{U+044B}") ;"ы" ; U+044B ы Cyrillic Small Letter Yeru 0531
<^>!+':: AltGrRemapFor_UKR("{U+042D}") ;"Э" ; U+042D Э Cyrillic Capital Letter E 0501
<^>!':: AltGrRemapFor_UKR("{U+044D}") ;"э" ; U+044D э Cyrillic Small Letter E 0533
<^>!+]:: AltGrRemapFor_UKR("{U+042A}") ;"Ъ" ; U+042A Ъ Cyrillic Capital Letter Hard Sign 0498
<^>!]:: AltGrRemapFor_UKR("{U+044A}") ;"ъ" ; U+044A ъ Cyrillic Small Letter Hard Sign 0530
<^>!+`:: AltGrRemapFor_UKR("{U+0401}") ;"Ё" ; U+0401 Ё Cyrillic Capital Letter Io 0457
<^>!`:: AltGrRemapFor_UKR("{U+0451}") ;"ё" ; U+0451 ё Cyrillic Small Letter Io 0537
; /*********************
; *** Kb-TR - CRH ***
; *** Ññ Ââ ***
; *********************/
; CRH -- Ññ Ââ
<^>!+n::
;if (Thread_GetKeyboardLanguage() = %G_KbL_8192%) {
; Send {U+00D1} ; U+00D1 Ñ 209 0303 0221 &Ntilde; Latin Capital letter N with tilde 0145
;} ;"Ñ"
;MsgBox % "(" . U+00D1 . "')\"
AltGrRemapFor_CRH("{U+00D1}") ;"Ñ" ; U+00D1 Ñ 209 0303 0221 &Ntilde; Latin Capital letter N with tilde 0145
return
<^>!n::
;if (Thread_GetKeyboardLanguage() = %G_KbL_8192%) {
; Send {U+00F1} ; U+00F1 ñ 241 0303 0261 &ntilde; Latin Small Letter N with tilde 0177
;} ;"ñ"
AltGrRemapFor_CRH("{U+00F1}") ;"ñ" ; U+00F1 ñ 241 0303 0261 &ntilde; Latin Small Letter N with tilde 0177
return
<^>!+a::
;if (Thread_GetKeyboardLanguage() = G_KbL_8192) {
; Send {U+00C2} ; U+00C2 Â 194 0303 0202 &Acirc; Latin Capital letter A with circumflex 0130
;} ;"Â"
AltGrRemapFor_CRH("{U+00C2}") ;"Â" ; U+00F1 ñ 241 0303 0261 &ntilde; Latin Small Letter N with tilde 0177
return
<^>!a::
;if (Thread_GetKeyboardLanguage() = G_KbL_8192) {
; Send {U+00E2} ; U+00E2 â 226 0303 0242 &acirc; Latin Small Letter A with circumflex 0162
;} ;"â"
AltGrRemapFor_CRH("{U+00E2}") ;"â" ; U+00E2 â 226 0303 0242 &acirc; Latin Small Letter A with circumflex 0162
return
; /*********************
; *** Kb-EN - CRH ***
; *** Ññ Ââ ***
; *********************/
; CRH -- Ññ Ââ Iı Ğğ Üü Şş İi Öö Çç
; AltGR Nn Aa Ii {[ }] :; "' <, >.
>!+n::
;if (Thread_GetKeyboardLanguage() = G_KbL_1033) {
; Send {U+00D1} ; U+00D1 Ñ 209 0303 0221 &Ntilde; Latin Capital letter N with tilde 0145
;} ;"Ñ"
AltGrRemapFor_ENG("{U+00D1}") ;"Ñ" ; U+00D1 Ñ 209 0303 0221 &Ntilde; Latin Capital letter N with tilde 0145
return
>!n::
;if (Thread_GetKeyboardLanguage() = G_KbL_1033) {
; Send {U+00F1} ; U+00F1 ñ 241 0303 0261 &ntilde; Latin Small Letter N with tilde 0177
;} ;"ñ"
AltGrRemapFor_ENG("{U+00F1}") ;"ñ" ; U+00F1 ñ 241 0303 0261 &ntilde; Latin Small Letter N with tilde 0177
return
>!+a::
;if (Thread_GetKeyboardLanguage() = G_KbL_1033) {
; Send {U+00C2} ; U+00C2 Â 194 0303 0202 &Acirc; Latin Capital letter A with circumflex 0130
;} ;"Â"
AltGrRemapFor_ENG("{U+00C2}") ; U+00C2 Â 194 0303 0202 &Acirc; Latin Capital letter A with circumflex 0130
return
>!a::
;if (Thread_GetKeyboardLanguage() = G_KbL_1033) {
; Send {U+00E2} ; U+00E2 â 226 0303 0242 &acirc; Latin Small Letter A with circumflex 0162
;} ;"â"
AltGrRemapFor_ENG("{U+00E2}") ;"â" ; U+00E2 â 226 0303 0242 &acirc; Latin Small Letter A with circumflex 0162
return
>!+i::
if (Thread_GetKeyboardLanguage() = G_KbL_1033) {
Send {U+0049} ; U+0049 I 73 0111 Latin Capital letter I 0042
} ;"I"
return
>!i::
if (Thread_GetKeyboardLanguage() = G_KbL_1033) {
Send {U+0131} ; U+0131 ı 305 &inodot; Latin Small Letter dotless I 0241
} ;"ı"
return
; ıI iİ 4900 3101
>!+[::
if (Thread_GetKeyboardLanguage() = G_KbL_1033) {
Send {U+011E} ; U+011E Ğ 286 &Gbreve; Latin Capital Letter G with breve 0222
} ;"Ğ"
return
>![::
if (Thread_GetKeyboardLanguage() = G_KbL_1033) {
Send {U+011F} ; U+011F ğ 287 &gbreve; Latin Small Letter G with breve 0223
} ;"ğ"
return
; U+011E U+011F
>!+]::
if (Thread_GetKeyboardLanguage() = G_KbL_1033) {
Send {U+00DC} ; U+00DC Ü 220 0303 0234 &Uuml; Latin Capital Letter U with diaeresis 0156
} ;"Ü"
return
>!]::
if (Thread_GetKeyboardLanguage() = G_KbL_1033) {
Send {U+00FC} ; U+00FC ü 252 0303 0274 &uuml; Latin Small Letter U with diaeresis 0188
} ;"ü"
return
; ]üÜ ,; U+00DC U+00FC
>!+;::
if (Thread_GetKeyboardLanguage() = G_KbL_1033) {
Send {U+015E} ; U+015E Ş 350 &Scedil; Latin Capital Letter S with cedilla 0286
} ;"Ş"
return
>!;::
if (Thread_GetKeyboardLanguage() = G_KbL_1033) {
Send {U+015F} ; U+015F ş 351 &scedil; Latin Small Letter S with cedilla 0287
} ;"ş"
return
; ;:;Şş U+015E U+015F
>!+'::
if (Thread_GetKeyboardLanguage() = G_KbL_1033) {
Send {U+0130} ; U+0130 İ 304 &Idot; Latin Capital Letter I with dot above 0240
} ;"İ"
return
>!'::
if (Thread_GetKeyboardLanguage() = G_KbL_1033) {
Send {U+0069} ; U+0069 i 105 0151 Latin Small Letter I 0074
} ;"i"
return
; '"'İi U+0130 U+0069
>!+,::
if (Thread_GetKeyboardLanguage() = G_KbL_1033) {
Send {U+00D6} ; U+00D6 Ö 214 0303 0226 &Ouml; Latin Capital letter O with diaeresis 0150
} ;"Ö"
return
>!,::
if (Thread_GetKeyboardLanguage() = G_KbL_1033) {
Send {U+00F6} ; U+00F6 ö 246 0303 0266 &ouml; Latin Small Letter O with diaeresis 0182
} ;"ö"
return
; <,Öö U+00D6 U+00F6
>!+.::
if (Thread_GetKeyboardLanguage() = G_KbL_1033) {
Send {U+00C7} ; U+00C7 Ç 199 0303 0207 &Ccedil; Latin Capital letter C with cedilla 0135
} ;"Ç"
return
>!.::
if (Thread_GetKeyboardLanguage() = G_KbL_1033) {
Send {U+00E7} ; U+00E7 ç 231 0303 0247 &ccedil; Latin Small Letter C with cedilla 0167
} ;"ç"
return
; >.Çç U+00C7 U+00E7
/*
;;; DEBUG ;;;;
F11::
Debug_F11()
;htkctl := Thread_GetKeyboardLanguage()
;MsgBox % A_Language . ": The variable F11 contains '" . htkctl . "' ('" . htkctl0 . "' '" . htkctl1 . "' '" . htkctl2 . "')." . G_KbL_8192
return
; ENG -- 0422: The variable F11 contains '1033' ('' '' '').
; UKR -- 0422: The variable F11 contains '1058' ('' '' '').
; CRH -- 0422: The variable F11 contains '8192' ('' '' '').
; UKR -- Ыы Ээ Ъъ Ёё
; CRH -- Ññ Ââ
; CRH -- Ññ Ââ Iı Ğğ Üü Şş İi Öö Çç
; https://en.wikipedia.org/wiki/List_of_Unicode_characters
*/
Debug_F11()
{
global G_KbL_8192 ; This word may be omitted if the first line of this function will be something like "local MyVar".
global htkctl0, htkctl1, htkctl2 ;
htkctl := Thread_GetKeyboardLanguage()
MsgBox % A_Language . ": The variable F11 contains '" . htkctl . "' ('" . htkctl0 . "' '" . htkctl1 . "' '" . htkctl2 . "')\" . G_KbL_8192 . "%" . %G_KbL_8192% . "%"
return
}
Thread_GetKeyboardLanguage()
{
global htkctl0, htkctl1, htkctl2 ;
WinGet, WinID,, A
ThreadID := DllCall("GetWindowThreadProcessId", "UInt", WinID, "UInt", 0)
InputLocaleID := DllCall("GetKeyboardLayout", "UInt", ThreadID, "UInt")
if ( ! InputLocaleID ) {
WinActivate, ahk_class WorkerW
WinGet, WinID2,, ahk_class WorkerW
ThreadID := DllCall("GetWindowThreadProcessId", "UInt", WinID2, "UInt", 0)
WinActivate, ahk_id %WinID%
InputLocaleID := DllCall("GetKeyboardLayout", "UInt", ThreadID, "UInt")
}
htkctl0 := InputLocaleID & 0x0000FFFF
htkctl1 := InputLocaleID & 0xFFFF0000 >> 16
htkctl2 := InputLocaleID & 0xFFFF00000000 ; >> 32
; MsgBox % A_Language . ": The variable MyVar contains " . htkctl0 . " (" . htkctl1 . " " . htkctl2 . ")."
return htkctl0
}
GetKeyboardLanguage()
{
if !KBLayout := DllCall("user32.dll\GetKeyboardLayout")
return false
return KBLayout & 0xFFFF
; return % "The variable MyVar contains " . KBLayout & 0xFFFF . "."
}
/*
if !KBLayoutNameA := DllCall("user32.dll\GetKeyboardLayoutNameA")
return false
EN - 1033
UK - 1058
CRH - 8192
CRH CYR = 9216
*/

AutoHotkey 1.x script for English, Ukrainian, Crimean Tatar, Russian symbols typing

Files

_.ahk

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment