Skip to content

Instantly share code, notes, and snippets.

@krin-san
Last active February 8, 2018 12:12
Show Gist options
  • Save krin-san/d1f110601b655bddb2d9 to your computer and use it in GitHub Desktop.
Save krin-san/d1f110601b655bddb2d9 to your computer and use it in GitHub Desktop.
AutoHotkey config file
; Store path: %userprofile%/Documents/AutoHotkey.ahk
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; Keyboard layout swithing
;
; See the language identifiers list here:
; http://msdn.microsoft.com/en-us/library/dd318693%28v=vs.85%29.aspx
;
SetLayout(lay)
{
PostMessage 0x50, 0, %lay%,, A
}
^+CapsLock::CapsLock
!CapsLock::SetLayout(0x4190419)
^CapsLock::SetLayout(0x4230423)
CapsLock::SetLayout(0x4090409)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; Text layout switcher (like Punto Switcher)
;
; Use AutoHotkey_L fork and save .ahk in CP1251 to support cyrillic characters
;
Translate()
{
Eng=qwertyuiop[]asdfghjkl;'zxcvbnm,.QWERTYUIOP{}ASDFGHJKL:"ZXCVBNM<>
Rus=йцукенгшщзхъфывапролджэячсмитьбюЙЦУКЕНГШЩЗХЪФЫВАПРОЛДЖЭЯЧСМИТЬБЮ
clipboard =
Send ^{sc02E} ; Ctrl+C
Sleep 10
ClipWait
r =
Loop, parse, clipboard
{
p := InStr(Eng, A_LoopField, true)
if p > 0
r := r . SubStr(Rus, p, 1)
else
{
p := InStr(Rus, A_LoopField, true)
if p > 0
r := r . SubStr(Eng, p, 1)
else
r := r . A_LoopField
}
}
SendInput {Del}%r% ; Replace
}
!+CapsLock::Translate()
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment