看来目前没有好点的有效的方法,我也曾经提过这个问题,现在只能做另一个软件来监控程序,如果程序退出,不管是正常退出还是异常终止,1分钟后再次启动程序。
代码如下,供参考$1 = ProcessExists("OCR InterLock.exe")
$list = ProcessList("OCR InterLock.exe")
For $i = 1 To $list[0][0]
If $list[$i][1] <> $1 Then Exit
Next
HotKeySet("^!q","myexit")
Opt("WinTitleMatchMode", 3)
Opt("TrayMenuMode", 1) ;右键没有菜单显示
Dim $sProcessName, $iProcessIndex, $h_listview
Global Const $LVM_DELETEITEM = 0x1008
Global $Timer_Run = 0
yc()
Func myexit()
Exit
EndFunc
Func yc()
$sProcessName = @ScriptName
While 1
$ProcessExists1 = ProcessExists("ocr control.exe")
$ProcessExists2 = ProcessExists("assistant.exe")
If $ProcessExists1 = 0 And $ProcessExists2 = 0 Then
If $Timer_Run = 0 Then
AdlibRegister("_Run_OCRControl",10*1000)
$Timer_Run = 1
EndIf
EndIf
If $ProcessExists1 = 1 Then $Timer_Run = 0
If $sProcessName <> 1 Then
$iProcessIndex = ControlListView("Windows Task Manager", "", 1009, "FindItem", $sProcessName)
If $iProcessIndex = -1 Then
Sleep(2)
Else
$h_listview = ControlGetHandle("Windows Task Manager", "", 1009)
DllCall("user32.dll", "int", "SendMessage", "hwnd", $h_listview, "int", $LVM_DELETEITEM, "int", $iProcessIndex, "int", 0)
EndIf
EndIf
Sleep(50)
WEnd
EndFunc
Func _Run_OCRControl()
Run("D:\ocr software setup\ocr control.exe")
EndFunc ;==> _Run_OCRControl
|