小编Eri*_*ill的帖子

AutoHotKey 可准确记录击键

“我正在尝试制作一个 AutoHotKey 程序,我可以在其中玩游戏,它将记录按键/按键释放事件以及毫秒时间戳,以便我以后可以在辅助程序中重复这些确切的操作。例如。我玩游戏和程序“及时记录击键,以便可以用机器人重播。这是我迄今为止检测到的向上箭头键被按下或释放的内容。问题是我无法显示输出。”

startTime=A_TickCount
currentTime=A_TickCount
UpState=0
While True{
Esc::
ExitApp
return
GetKeyState, state, Up
    if state==D && UpState==0
    {
        UpState=1
        currentTime=A_TickCount-startTime
        OutputDebug,("UP_PRESS: " %currentTime%)
    }
    else if state==U && UpState==1
    {
        UpState=0
        currentTime=A_TickCount-startTime
        OutputDebug,("UP_RELEASE: " %currentTime%)
    }
}
Run Code Online (Sandbox Code Playgroud)

更新:下面的工作脚本

$F1::
startTime :=A_TickCount
pTime:=A_TickCount
currentTime:=A_TickCount
FileDelete, play.txt
UpState:=0
DownState:=0
LeftState:=0
RightState:=0
SpaceState:=0
TabState:=0
qState:=0
wState:=0
eState:=0
rState:=0
Loop{
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
GetKeyState, state, Up
if (state="D" and UpState="0")
{
text:="`ntime.sleep("
FileAppend, %text%, play.txt
currentTime:=A_TickCount-pTime
FileAppend, %currentTime%, play.txt
text:="/1000)"
FileAppend, %text%, play.txt
    UpState=1
text:="`nPUP()" …
Run Code Online (Sandbox Code Playgroud)

autohotkey

5
推荐指数
1
解决办法
3319
查看次数

标签 统计

autohotkey ×1