我希望ahk_exe QTranslate.exe
一旦另一个程序ahk_exe pycharm64.exe
关闭,它就自动在系统托盘中运行。
我尝试过这个:
Loop {
if WinExist("ahk_exe pycharm64.exe")
WinWaitClose, ahk_exe pycharm64.exe
Run, "C:\Program Files (x86)\QTranslate\QTranslate.exe",,hide
}
问题在于,QTranslate
窗口总是连续出现,当我关闭它时,它会不停地出现,并且QTranslate
不会在系统托盘中开始运行,而当ahk_exe pycharm64.exe
它不存在时就会发生这种情况。
答案1
#Persistent
SetTimer, run_QTranslate, 500
return
run_QTranslate:
If ProcessExist("QTranslate.exe")
return ; do nothing
; otherwise:
If ProcessExist("pycharm64.exe")
{
Process, WaitClose, pycharm64.exe
SetTimer, run_QTranslate, Off ; turns the timer off
Run, "C:\Program Files (x86)\QTranslate\QTranslate.exe",,hide
Process, WaitClose, QTranslate.exe
SetTimer, run_QTranslate, On ; for next time pycharm64.exe exists
}
return
ProcessExist(name){
Process, Exist, %name%
return Errorlevel
}