AHK:GetKeyState,无法发送 2 个命令

AHK: GetKeyState, can't send 2 commands

基本上我想做的是:当我按住 "a" 键时,脚本会自动按住并一遍又一遍地释放 "a" 键。它还必须按下或 hold/release "h" 键。当我尝试添加 "h"-key 时它给我带来了问题(每当我激活脚本而不是等待 "a"-press 时它会向 "h"-key 发送垃圾邮件)。

#Persistent

SetTimer, Clicking

F2::ExitApp

Clicking:

a::
if (GetKeyState("a", "P"))
   Send {a down} 
   Send {h down} 
   Sleep 100
   Send {h up} 
   Send {a up} 
   Sleep 475

Return 

a up:: Send {a up} 

如有任何帮助,我们将不胜感激! :-)

您的 if 块需要用大括号括起来:

if (GetKeyState("a", "P"))
{
   Send {a down} 
   Send {h down} 
   ...
}