Page 1 of 1

loop to process

Posted: 30 Aug 2016, 04:58
by Tomer
Hello,

I need help with writing a script that run with a "loop" or "wait" and checking if cmd.exe process is running,
if the process is running, then do nothing,
when the process is stops and not running anymore, then popup a msgbox: "cmd process not running anymore".

Tnx!

Re: loop to process

Posted: 30 Aug 2016, 07:17
by Tomer
I have done this and need more help with the code please.

Code: Select all

loop
{
IfWinNotExist, ahk_exe cmd.exe
msgbox,64,,cmd process not running anymore
}

Re: loop to process

Posted: 30 Aug 2016, 07:33
by boiler
Your code works, but it's better to use WinWaitClose than IfWinNotExist in this case so it doesn't continuously loop while waiting for it to close.

Re: loop to process

Posted: 30 Aug 2016, 07:55
by Tomer
Tnx,
but I had to start the loop after the IfWinNotExist:

Code: Select all

loop
IfWinNotExist, ahk_exe cmd.exe
{
	msgbox,64,,cmd.exe process not running
	break
}

Re: loop to process

Posted: 30 Aug 2016, 08:06
by boiler
It's still looping continuously while waiting for it to close, where it wouldn't do that if you use WinWaitClose instead (and put it in the loop). I haven't checked, but I would think your version uses a lot more CPU time.