From 0d06746c0f736b1162b69ed9e20f14e7fc4e96b7 Mon Sep 17 00:00:00 2001 From: Xuesong Peng Date: Mon, 7 Oct 2024 12:30:51 +0800 Subject: [PATCH] fix: customize keyboard layout workaround for #6 --- Rabbit.ahk | 28 +++++++++++++++++++++++++++- schemas/jiandao-src | 2 +- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/Rabbit.ahk b/Rabbit.ahk index 924c0f7..98e6995 100644 --- a/Rabbit.ahk +++ b/Rabbit.ahk @@ -122,7 +122,33 @@ RabbitMain(args) { } ; https://www.autohotkey.com/boards/viewtopic.php?f=76&t=101183 -SetDefaultKeyboard(locale_id := 0x0409) { +SetDefaultKeyboard(locale_id := 0) { + if !locale_id { + local key_map := Map( + "EN_US", 0x0409, + "EN_GB", 0x0809, + "EN_HK", 0x3c09, + ) + local lang_path := RabbitUserDataPath() . "\.lang" + if FileExist(lang_path) { + local lang := FileRead(lang_path, "UTF-8") + local valid := lang && key_map.Has(StrUpper(StrReplace(lang, "-", "_"))) + if !lang || !valid { + input_box := InputBox("当玉兔毫启动时,会将系统键盘切换到对应语言", "请输入语言代码", , "en_US") + if input_box.Result == "OK" { + lang := input_box.Value + } + if lang && key_map.Has(StrUpper(StrReplace(lang, "-", "_"))) { + FileDelete(lang_path) + FileAppend(lang, lang_path, "UTF-8") + } + } + try + locale_id := key_map[StrUpper(StrReplace(lang, "-", "_"))] + } + if !locale_id + locale_id := 0x0409 + } local HWND_BROADCAST := 0xffff local LOW_WORD := 0xffff local WM_INPUTLANGCHANGEREQUEST := 0x0050 diff --git a/schemas/jiandao-src b/schemas/jiandao-src index 0537ddf..dbe5a50 160000 --- a/schemas/jiandao-src +++ b/schemas/jiandao-src @@ -1 +1 @@ -Subproject commit 0537ddf011737e1df02936a58d4d3cea9a28d70e +Subproject commit dbe5a50dc9d307c84bcf57c8d67ef425cb6c81a0