search process

Ask gaming related questions (AHK v1.1 and older)
Hidrick
Posts: 18
Joined: 27 Jun 2016, 08:28

search process

Post by Hidrick » 02 Jul 2022, 22:06

Hello!
I am trying to write a script to search if a process is runing, if its not runing then open it.
did i missed something?

Code: Select all

#MaxThreadsPerHotkey 2
F12::pause
F10::reload
F11::
	Loop
	{
		Process, Exist, window.exe ; check to see if window.exe is running
		If (ErrorLevel != 0)
				{
				Run, ‪C:\Users\User\Downloads\lostbait\window.exe
				Return
				}
			else
				{
				Return
				}
		Sleep 30000	; sleep 30 secs
	}

User avatar
boiler
Posts: 16771
Joined: 21 Dec 2014, 02:44

Re: search process

Post by boiler » 02 Jul 2022, 22:28

You return after either result, so it stops the loop right there. Try this:

Code: Select all

#MaxThreadsPerHotkey 2
F12::pause
F10::reload
F11::
	Loop
	{
		Process, Exist, window.exe ; check to see if window.exe is running
		If (ErrorLevel != 0)
			Run, ‪C:\Users\User\Downloads\lostbait\window.exe
		Sleep 30000	; sleep 30 secs
	}
return

User avatar
boiler
Posts: 16771
Joined: 21 Dec 2014, 02:44

Re: search process

Post by boiler » 02 Jul 2022, 22:32

Actually, you want to run it if ErrorLevel is 0. If it’s not 0, then it already exists, so remove the ! in addition to the above changes.

Hidrick
Posts: 18
Joined: 27 Jun 2016, 08:28

Re: search process

Post by Hidrick » 02 Jul 2022, 22:48

oh, seems like i miss understood the !=0
ty boiler! the script launched the .exe

Post Reply

Return to “Gaming Help (v1)”