AutoHotKey:等待进程,中断用户输入
AutoHotKey: wait for process, breaking on user input
脚本正在等待进程启动;它将无限期地这样做,但前提是没有人为输入。换句话说:脚本应等待进程启动或人工输入,以先到者为准(此外,脚本启动时进程可能已经 运行,在这种情况下,脚本应立即关闭)。我想到了这样的事情,但可能有更好的方法,因为这个循环不会因输入而中断:
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
}
脚本正在等待进程启动;它将无限期地这样做,但前提是没有人为输入。换句话说:脚本应等待进程启动或人工输入,以先到者为准(此外,脚本启动时进程可能已经 运行,在这种情况下,脚本应立即关闭)。我想到了这样的事情,但可能有更好的方法,因为这个循环不会因输入而中断:
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
}