Run only when process is not running

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
rspai
Posts: 9
Joined: 15 Oct 2019, 03:38

Run only when process is not running

15 Oct 2019, 04:04

I am a new to AHK.

I want to run a playlist file (mpcpl file- test.mpcpl) if the MPC-Player( process "mpc-hc.exe") is not running. I am trying with the script below. It runs the playlist when mpc-hc.exe is running as well as when it is not running. Please help.


Code: Select all

!n::
If !ProcessExist("mpc-hc.exe")
{
Msgbox, mpc-hc.exe does not exist
Run, K:\May2017\test.mpcpl
}

If ProcessExist("mpc-hc.exe")
{
Msgbox, mpc-hc.exists
}

ProcessExist(Name){
	Process,Exist,%Name%
	return Errorlevel
}
Return
User avatar
boiler
Posts: 17384
Joined: 21 Dec 2014, 02:44

Re: Run only when process is not running

15 Oct 2019, 08:19

The script works when tested with a known process like notepad.exe. Are you sure your process is named exactly mpc-hc.exe? You could try using WinExist to look for the player window instead of looking for the process.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Bing [Bot], fiaztv1, Google [Bot], JKJadan, Pianist and 175 guests