这是我到目前为止写的脚本。它只能部分起作用。我需要它来采取的pc屏幕截图后,只播放了一个警报。当我运行脚本时,它会立即截取屏幕截图,并将其保存在正确的文件名和位置下,然后关闭mspaint。然后,它将每隔20秒循环一次,并执行另一次循环。我的while命令出了点问题,我就是搞不清楚。我是如何阅读我的语法的,它应该停留在while循环中,直到时间少于20秒。然后,一旦文件被访问,就退出while循环并继续执行无限循环。
Loop {
FileGetTime, LastTime, alarm.wav, A
Elapsed := A_Now - LastTime
while (Elapsed > 20000){
FileGetTime, LastTime, alarm.wav, A
Elapsed := A_Now - LastTime
}
send {PrintScreen}
Run, MSPaint
WinWaitActive, Untitled - Paint
Send ^v
Sleep, 50
Send ^s
Sleep, 50
Send c:\Screenshots\
Send %A_Now%
Sleep, 100
Send {Enter}
Sleep, 2000
WinClose, ahk_exe MSPaint.exe
Sleep, 20000
}发布于 2016-08-19 01:10:19
我通过把一个
MsgBox %Elapsed%在while循环中。它计算秒,而不是毫秒。将while公式从20000降低到20,现在它可以工作了。
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
LastTime = 0
Loop
{
Elapsed = 30
while (Elapsed > 20)
{
FileGetTime, LastTime, alarm.wav, A
Elapsed := A_Now - LastTime
}
send {PrintScreen}
Run, MSPaint
WinWaitActive, Untitled - Paint
Send ^v
Sleep, 50
Send ^s
Sleep, 200
Send c:\Screenshots\%A_Now%
Sleep, 100
Send {Enter}
Sleep, 200
WinClose, ahk_exe MSPaint.exe
Sleep, 20000
}https://stackoverflow.com/questions/39022555
复制相似问题