blender 解决shift快捷键和中英切换重复的问题
问题
键盘shift切换中英输入快捷键,blender里面很多长按shift的,比如视角的平移会导致键盘输入法切换,然后快捷键失效。
解决
思路
- 如果是在blender活动窗口里面
- 长按shift的时候,不切换中英文。如果按住时间超过200ms,松开后默认自动再触发一次shift。
- 短按shift的时候,切换中英文
- 如果时间短与200ms,但是是组合键盘 (例如shift+a),松开后默认自动再触发一次shift。
工具:
autohotkey(https://www.autohotkey.com/)
脚本:
#Requires AutoHotkey v2.0#HotIf WinActive("ahk_exe blender.exe")~LShift::
{start := A_TickCountKeyWait("LShift", "U")duration := A_TickCount - startif (duration > 200) {Send("{LShift}")} else {if (AnyOtherKeyDown("LShift"))Send("{LShift}")}
}~RShift::
{start := A_TickCountKeyWait("RShift", "U")duration := A_TickCount - startif (duration > 200) {Send("{RShift}")} else {if (AnyOtherKeyDown("RShift"))Send("{RShift}")}
}#HotIf; 检查除 shift 本身的其他键是否按下
AnyOtherKeyDown(shiftKey) {keys := ["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","1","2","3","4","5","6","7","8","9","0","Space","Tab","Enter","Up","Down","Left","Right","Insert","Delete","Home","End","PgUp","PgDn","F1","F2","F3","F4","F5","F6","F7","F8","F9","F10","F11","F12"]for key in keys {; 排除当前 Shiftif (key = shiftKey)continueif (GetKeyState(key, "P"))return true}return false
}