Created
January 21, 2023 00:33
-
-
Save eiennohito/5253c3d30816239d68e02384f8e83291 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases. | |
SendMode Input ; Recommended for new scripts due to its superior speed and reliability. | |
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory. | |
global lang_ru := DllCall("LoadKeyboardLayout", "Str", "00000419", "Int", 0x3) | |
;MsgBox % Format("{:X} {:X}", lang_ru, ErrorLevel) | |
global lang_ja := DllCall("LoadKeyboardLayout", "Str", "00000411", "Int", 0x3) | |
;MsgBox % Format("{:X} {:X}", lang_ja, ErrorLevel) | |
SwitchLang() { | |
w := DllCall("GetForegroundWindow") | |
pid := DllCall("GetWindowThreadProcessId", "UInt", w, "Ptr", 0) | |
cur_layout := DllCall("GetKeyboardLayout", "UInt", pid) | |
;MsgBox % Format("lang is {:X} {:X} {:X}", cur_layout, lang_ru, lang_ja) | |
If (cur_layout = lang_ja) { | |
;0x50 WM_INPUTLANGCHANGEREQUEST | |
PostMessage, 0x50, 0, %lang_ru%,,A | |
} Else { | |
PostMessage, 0x50, 0, %lang_ja%,,A | |
} | |
} | |
; use Muhenkan keys in addition to control keys for common shortcuts | |
sc07B & c::^c | |
sc07B & v::^v | |
sc07B & x::^x | |
sc07B & z::^z | |
sc07B & t::^t | |
sc07B & w::^w | |
sc07B & f::^f | |
sc07B & s::^s | |
sc07B & r::^r | |
; em dash | |
sc07B & -::Send {U+2014} | |
; switch between ru and ja layouts by muhenkan-space | |
sc07B & Space::SwitchLang() | |
; CapsLock::Ctrl | |
; VKEBSC07B::Send, {Ctrl} | |
; VKEBSC07B Space::>#Space |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment