Process 自动热键:等待进程,在用户输入时中断

Process 自动热键:等待进程,在用户输入时中断,process,user-input,autohotkey,Process,User Input,Autohotkey,脚本正在等待进程启动;它将无限期地这样做,但前提是没有人力投入。换句话说:脚本应等待进程启动或人工输入,以先到者为准。当脚本启动时,进程可能已经在运行,在这种情况下,脚本应立即关闭。我曾经想过这样的事情,但可能有更好的方法,因为这个循环不会因输入而中断: while (A_TimeIdlePhysical > 100) { Process, Wait, SomeProcess.exe } 有什么想法吗?用记事本测试: #Persistent SetTimer, DetectPro

脚本正在等待进程启动;它将无限期地这样做,但前提是没有人力投入。换句话说:脚本应等待进程启动或人工输入,以先到者为准。当脚本启动时,进程可能已经在运行,在这种情况下,脚本应立即关闭。我曾经想过这样的事情,但可能有更好的方法,因为这个循环不会因输入而中断:

while (A_TimeIdlePhysical > 100) {
    Process, Wait, SomeProcess.exe
}
有什么想法吗?

用记事本测试:

#Persistent
SetTimer, DetectProcess, 50
return

DetectProcess:
If (ProcessExist("notepad.exe")) ; if the process is already running
    ExitApp
; otherwise:
If (A_TimeIdlePhysical > 100) ; as long as there is no human input
{
    If (ProcessExist("notepad.exe"))  ; wait for either process start
        ExitApp
}
else ;  or human input
    ExitApp
return

ProcessExist(ProcessName){
Process, Exist, %ProcessName%
return Errorlevel
}