Skip to content

Commit

Permalink
feat: LCtrl + Space toggle Rabbit suspending
Browse files Browse the repository at this point in the history
  • Loading branch information
amorphobia committed Sep 7, 2024
1 parent ce2b848 commit 141ed23
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 23 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@
- 因热键冲突而取消了一些按键注册
- 与某些软件适配较差
- 桌面版 QQ 的密码输入框无法使用:[QQ密码输入框(防键盘钩子)原理分析](https://blog.csdn.net/muyedongfeng/article/details/49308993)
[页面存档备份](https://web.archive.org/web/20240907052640/https://blog.csdn.net/muyedongfeng/article/details/49308993),存于互联网档案馆)
[页面存档备份](https://web.archive.org/web/20240907052640/https://blog.csdn.net/muyedongfeng/article/details/49308993),存于互联网档案馆),请使用 <kbd>LCtrl</kbd> + <kbd>Space</kbd> 禁用 / 启用玉兔毫(左控制键加空格键,暂不支持自定义按键)
53 changes: 31 additions & 22 deletions Rabbit.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -127,55 +127,64 @@ RegisterHotKeys() {
if modifier == "LWin" or modifier == "RWin" or modifier == "LAlt" or modifier == "RAlt"
continue ; do not register Win / Alt keys for now
local mask := KeyDef.mask[modifier]
Hotkey("$" . modifier, ProcessKey.Bind(modifier, mask))
Hotkey("$" . modifier . " Up", ProcessKey.Bind(modifier, mask | up))
Hotkey("$" . modifier, ProcessKey.Bind(modifier, mask), "S0")
Hotkey("$" . modifier . " Up", ProcessKey.Bind(modifier, mask | up), "S0")
}

; Plain
Loop 2 {
local key_map := A_Index = 1 ? KeyDef.plain_keycode : KeyDef.other_keycode
for key, _ in key_map {
Hotkey("$" . key, ProcessKey.Bind(key, 0))
Hotkey("$" . key, ProcessKey.Bind(key, 0), "S0")
; need specify left/right to prevent fallback to modifier down/up hotkeys
Hotkey("$<^" . key, ProcessKey.Bind(key, ctrl))
if key = "Space"
Hotkey("$<^" . key, ProcessKey.Bind(key, ctrl), "S")
else
Hotkey("$<^" . key, ProcessKey.Bind(key, ctrl), "S0")
; do not register Alt + single key now
; if not key = "Tab" {
; Hotkey("$<!" . key, ProcessKey.Bind(key, alt))
; Hotkey("$>!" . key, ProcessKey.Bind(key, alt))
; Hotkey("$<!" . key, ProcessKey.Bind(key, alt), "S0")
; Hotkey("$>!" . key, ProcessKey.Bind(key, alt), "S0")
; }
Hotkey("$>^" . key, ProcessKey.Bind(key, ctrl))
Hotkey("$^!" . key, ProcessKey.Bind(key, ctrl | alt))
Hotkey("$!#" . key, ProcessKey.Bind(key, alt | win))
Hotkey("$>^" . key, ProcessKey.Bind(key, ctrl), "S0")
Hotkey("$^!" . key, ProcessKey.Bind(key, ctrl | alt), "S0")
Hotkey("$!#" . key, ProcessKey.Bind(key, alt | win), "S0")

; Do not register Win keys for now
; Hotkey("$<#" . key, ProcessKey.Bind(key, win))
; Hotkey("$>#" . key, ProcessKey.Bind(key, win))
; Hotkey("$^#" . key, ProcessKey.Bind(key, ctrl | win))
; Hotkey("$^!#" . key, ProcessKey.Bind(key, ctrl | alt | win))
; Hotkey("$<#" . key, ProcessKey.Bind(key, win), "S0")
; Hotkey("$>#" . key, ProcessKey.Bind(key, win), "S0")
; Hotkey("$^#" . key, ProcessKey.Bind(key, ctrl | win), "S0")
; Hotkey("$^!#" . key, ProcessKey.Bind(key, ctrl | alt | win), "S0")
}
}

; Shifted
Loop 2 {
local key_map := A_Index = 1 ? KeyDef.shifted_keycode : KeyDef.other_keycode
for key, _ in key_map {
Hotkey("$<+" . key, ProcessKey.Bind(key, shift))
Hotkey("$>+" . key, ProcessKey.Bind(key, shift))
Hotkey("$+^" . key, ProcessKey.Bind(key, shift | ctrl))
Hotkey("$<+" . key, ProcessKey.Bind(key, shift), "S0")
Hotkey("$>+" . key, ProcessKey.Bind(key, shift), "S0")
Hotkey("$+^" . key, ProcessKey.Bind(key, shift | ctrl), "S0")
if not key == "Tab"
Hotkey("$+!" . key, ProcessKey.Bind(key, shift | alt))
Hotkey("$+^!" . key, ProcessKey.Bind(key, shift | ctrl | alt))
Hotkey("$+!" . key, ProcessKey.Bind(key, shift | alt), "S0")
Hotkey("$+^!" . key, ProcessKey.Bind(key, shift | ctrl | alt), "S0")

; Do not register Win keys for now
; Hotkey("$+#" . key, ProcessKey.Bind(key, shift | win))
; Hotkey("$+^#" . key, ProcessKey.Bind(key, shift | ctrl | win))
; Hotkey("$+!#" . key, ProcessKey.Bind(key, shift | alt | win))
; Hotkey("$+^!#" . key, ProcessKey.Bind(key, shift | ctrl | alt | win))
; Hotkey("$+#" . key, ProcessKey.Bind(key, shift | win), "S0")
; Hotkey("$+^#" . key, ProcessKey.Bind(key, shift | ctrl | win), "S0")
; Hotkey("$+!#" . key, ProcessKey.Bind(key, shift | alt | win), "S0")
; Hotkey("$+^!#" . key, ProcessKey.Bind(key, shift | ctrl | alt | win), "S0")
}
}
}

ProcessKey(key, mask, this_hotkey) {
if key = "Space" and mask == KeyDef.mask["Ctrl"] {
Suspend(-1)
ToolTip(A_IsSuspended ? "禁用" : "启用", , , STATUS_TOOLTIP)
SetTimer(() => ToolTip(, , , STATUS_TOOLTIP), -2000)
return
}
global last_is_hide
local code := 0
Loop 4 {
Expand Down

0 comments on commit 141ed23

Please sign in to comment.