
我試圖使用 AutoHotKey 來獲得以下行為:A
按下該鍵時,AHK 按住該S
鍵直到D
按下該鍵。以下腳本未如預期運作:
a::
Send {s Down}
return
d::
if (GetKeyState("s", "P"))
{
Send {s Up}
}
return
以下也不是:
a::
release_s = 0
Loop
{
SendInput, s
if release_s
break
}
return
d::
release_s = 1
return
答案1
試試這個:
a::Send, {s down}
d::
if(GetKeyState("s")) {
Send, {s up}
}
return
您的程式碼中存在問題:
GetKeyState("s", "P")
將僅佔身體的鍵。S另一方面已作為虛擬的由 AHK 密鑰。
答案2
發送 {s Down} 不會導致按鍵重複。您需要使用循環。試試一下:
a::
stop = 0
Loop
{
SendInput, s
Sleep 50 ;adjust for speed of repetition
if stop
break
}
return
d::
stop = 1
return