Skip to content

Commit 0d06746

Browse files
committed
fix: customize keyboard layout
workaround for #6
1 parent c189fe7 commit 0d06746

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

Rabbit.ahk

+27-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,33 @@ RabbitMain(args) {
122122
}
123123

124124
; https://www.autohotkey.com/boards/viewtopic.php?f=76&t=101183
125-
SetDefaultKeyboard(locale_id := 0x0409) {
125+
SetDefaultKeyboard(locale_id := 0) {
126+
if !locale_id {
127+
local key_map := Map(
128+
"EN_US", 0x0409,
129+
"EN_GB", 0x0809,
130+
"EN_HK", 0x3c09,
131+
)
132+
local lang_path := RabbitUserDataPath() . "\.lang"
133+
if FileExist(lang_path) {
134+
local lang := FileRead(lang_path, "UTF-8")
135+
local valid := lang && key_map.Has(StrUpper(StrReplace(lang, "-", "_")))
136+
if !lang || !valid {
137+
input_box := InputBox("当玉兔毫启动时,会将系统键盘切换到对应语言", "请输入语言代码", , "en_US")
138+
if input_box.Result == "OK" {
139+
lang := input_box.Value
140+
}
141+
if lang && key_map.Has(StrUpper(StrReplace(lang, "-", "_"))) {
142+
FileDelete(lang_path)
143+
FileAppend(lang, lang_path, "UTF-8")
144+
}
145+
}
146+
try
147+
locale_id := key_map[StrUpper(StrReplace(lang, "-", "_"))]
148+
}
149+
if !locale_id
150+
locale_id := 0x0409
151+
}
126152
local HWND_BROADCAST := 0xffff
127153
local LOW_WORD := 0xffff
128154
local WM_INPUTLANGCHANGEREQUEST := 0x0050

0 commit comments

Comments
 (0)