而 GetKeyState 无缘无故地发送 ESC

问题描述

我在松开按钮后做了一个函数 (f4) 该函数发送 ESC 2 次 我用 } 关闭函数后写了 Send {esc} 来反击它 我仍然可以看到它发生并且它触发了我。 有解决办法吗?

~^f4::
DllCall("mouse_event","UInt",0x01,950)
Sleep,100
Send {x}
Sleep,100
while GetKeyState("f4")
{
Sleep,100
Send {r}
Sleep,100
Send {enter}
Sleep,30
Send {esc}
Sleep,100
DllCall("mouse_event",-950)
Sleep,100
Send {e}
Sleep,100
Send {Left}
Sleep,5
Send {Left}
Sleep,50
Send {enter}
Sleep,10
Send {esc}
Sleep,950)
}
Send {esc}
return

解决方法

基于我理解的解决方案:

~^f4::
DllCall("mouse_event","UInt",0x01,950)
Sleep,100
Send {x}
Sleep,100
while GetKeyState("f4")
{
Sleep,100
Send {r}
Sleep,100
Send {enter}
Sleep,30
if !GetKeyState("f4")
    break
Send {esc}
Sleep,100
DllCall("mouse_event",-950)
Sleep,100
Send {e}
Sleep,100
Send {Left}
Sleep,5
Send {Left}
Sleep,50
Send {enter}
Sleep,10
if !GetKeyState("f4")
    break
Send {esc}
Sleep,950)
}
Send {esc}
return