为什么我的脚本在ScummVM关闭后不执行?

时间:2017-08-24 05:40:36

标签: autohotkey

我的脚本确实可以使用while循环。 ScummVM正确启动。

但是,我希望脚本执行的操作是在检测到scummvm.exe已关闭时继续运行并执行命令。每次我关闭scummvm,都没有任何反应。

#NoTrayIcon
#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.

RunWait, "..\sc55 scummvm.exe"
Run, ".\scummvm.exe" "--no-console" "--config=.\scummvm.ini" "samnmax"
Process, Exist, scummvm.exe ;wait until scummvm.exe is found before continuing
ScummVM = %ErrorLevel%  ; Save the value immediately since ErrorLevel is often changed.
while ScummVM != 0 ;while scummvm is running i.e., error level is not equal to 0
{} ;"do nothing"
msgbox "scummvm has closed" ;action taken when scummvm is closed
return

1 个答案:

答案 0 :(得分:1)

scummvm.exe退出后执行命令

RunWait, "..\sc55 scummvm.exe"
Run, ".\scummvm.exe" "--no-console" "--config=.\scummvm.ini" "samnmax"
loop {
  sleep 5000    ; 5 seconds
  Process, Exist, scummvm.exe
} until ErrorLevel == 0
msgbox "scummvm has closed"
return