我正在渲染一个Adobe After Effects项目,使用Autoit和aerender,我将这行代码放在控制台中:
aerender -project C:\aeProjects\projekt_1.aep -comp "Main" -output C:\aeProjects\output\asd.avi现在,我如何检查此过程是否已完成,以便可以安全地继续执行其他步骤。目前我只是睡了一觉,但我认为这不是一个好的做法。
发布于 2015-11-16 22:57:12
您可以使用ProcessExists函数来完成此操作。
下面是一个带有超时选项的简单示例:
MsgBox(64, "RunCmdWait", RunCmdWait("notepad.exe"))
Func RunCmdWait($sRuncmd, $iTimeout = 10000)
Local $iPid = Run(@ComSpec & " /c " & $sRuncmd, @ScriptDir, @SW_HIDE, 6)
Local $hTimer = TimerInit() ; Begin the timer and store the handle in a variable.
While 1
Sleep(250)
;Returns 0 when the process is closed
If ProcessExists($iPid) = 0 Then
SetError(0)
ExitLoop
EndIf
;Returns 1 on time out error
If TimerDiff($hTimer) >= $iTimeout Then
SetError(1)
ExitLoop
EndIf
WEnd
Return @error
EndFunc ;==>RunCmdWait如果您需要读取输出,下面是一个使用StdoutRead的示例:
MsgBox(64, "StdoutRead", GetStdoutRead("dir"))
Func GetStdoutRead($sRuncmd)
Local $iPid = Run(@ComSpec & " /c " & $sRuncmd, @ScriptDir, @SW_HIDE, 6)
Local $sStdoutRead = ""
While ProcessExists($iPid)
$sStdoutRead &= StdoutRead($iPid)
WEnd
Return $sStdoutRead
EndFunc ;==>GetStdoutReadhttps://stackoverflow.com/questions/33731448
复制相似问题