这是一个例子。我基本上想检查按 Shift 和 1 是否等于! (英文键盘上就是这种情况)
x = +1
if (x = !) {
Send abc
}
上面的代码当然是错误的,但是可以做这样的事情吗?
编辑:
我只想检查我使用的是哪种语言设置,因为脚本的一部分仅在我使用日语键盘时才应启用,而一部分仅在我使用英语或德语键盘时启用。
例如,如果按“a”显示“a”,那么我使用的是英语或德语键盘,如果按“a”显示“あ”,那么我使用的是日语键盘。
如果脚本的这些部分不是很长和复杂并且仅包含热键/热字符串,您可以尝试以下操作:
; English/German part:
; add here the english/german hotkeys/hotstrings
; Japanese part:
#IF GetKeyboardLanguage(WinActive("A")) = 0x0411 ; Japanese
; add here the japanese hotkeys/hotstrings
#IF ; turn off context sensitivity
GetKeyboardLanguage(_hWnd=0){
; https://autohotkey.com/board/topic/116538-detect-which-language-is-currently-on/#entry672236
if !_hWnd
ThreadId=0
else
if !ThreadId := DllCall("user32.dll\GetWindowThreadProcessId", "Ptr", _hWnd, "UInt", 0, "UInt")
return false
if !KBLayout := DllCall("user32.dll\GetKeyboardLayout", "UInt", ThreadId, "UInt")
return false
return KBLayout & 0xFFFF
}
; Language Identifiers and Locales
; https://learn.microsoft.com/en-us/previous-versions/ms957130(v=msdn.10)