こんな感じ?
#NoEnv
~Shift::
AnyKeyPress:=0
KeyHook(true, 0xA0)
KeyWait, vkA0
KeyHook(false)
If (!AnyKeyPress)
Send, {Space}
Return
KeyHook(enable, ignoreVKey="") {
static hModule, hKeybordLL, hHook, keyInfo:="0000"
If (!hKeybordLL)
hKeybordLL:=RegisterCallback("KeybordLL", "", 3, &keyInfo), hModule:=DllCall("kernel32.dll\GetModuleHandle", "UInt",0, "UInt")
If (!hHook && enable) {
NumPut(ignoreVKey, keyInfo, 0, "Int")
Return (hHook:=DllCall("user32.dll\SetWindowsHookEx", "Int",0x0D, "UInt",hKeybordLL, "UInt",hModule, "UInt",0, "Int"))>0
} Else If DllCall("user32.dll\UnhookWindowsHookEx", "UInt",hHook, "Int") && !(hHook:=0)
Return true
}
KeybordLL(nCode, wParam, lParam) {
global AnyKeyPress
vk:=NumGet(lParam+0, 0, 4), ignoreVKey:=NumGet(A_EventInfo+0, 0, "Int"), AnyKeyPress |= (vk != ignoreVKey)
Return (wParam==0x100 && vk==ignoreVKey) ? 1 : DllCall("user32.dll\CallNextHookEx", "UInt",0, "Int",nCode, "UInt",wParam, "UInt",lParam, "Int")
}
キーフック使わないで、任意のキーが押されたかどうかを判定する方法ってあるのかな。