loop to process

Get help with using AutoHotkey and its commands and hotkeys
User avatar
Tomer
Posts: 314
Joined: 21 Aug 2016, 05:11

loop to process

30 Aug 2016, 04:58

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!
User avatar
Tomer
Posts: 314
Joined: 21 Aug 2016, 05:11

Re: loop to process

30 Aug 2016, 07:17

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
}
User avatar
boiler
Posts: 5905
Joined: 21 Dec 2014, 02:44

Re: loop to process

30 Aug 2016, 07:33

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.
User avatar
Tomer
Posts: 314
Joined: 21 Aug 2016, 05:11

Re: loop to process

30 Aug 2016, 07:55

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
}
User avatar
boiler
Posts: 5905
Joined: 21 Dec 2014, 02:44

Re: loop to process

30 Aug 2016, 08:06

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.

Return to “Ask For Help”

Who is online

Users browsing this forum: Albireo, mikeyww, PlumpSamurai, RubbeH, Stewn, XShayanX and 34 guests