EDIT by Pfeil: The "{PROCESSCOUNT:}" token was implemented in v1.7.1, and is now a native feature that does not require an inline function
VoiceAttack currently does not have a "{PROCESSEXISTS:}" token, but I believe this functionality would be useful to have. So as a workaround we can achieve this with an inline function.
// Define the process (or application) name you want to check
Set Text [~ProcessToCheck] to 'mspaint'
// Search for the specified process among all running processes
Inline C# Function: Check if process is running, wait until execution finishes
// Perform additional actions based on result of process search
Begin Boolean Compare : [ProcessCheckResult] Equals True
Say, 'Process is running'
Else
Say, 'Process not found'
End Condition
...with the inline function using System.dll as the referenced assembly along with the following code:
using System.Diagnostics;
public class VAInline
{
public void main()
{
string processName = VA.GetText("~ProcessToCheck");
Process[] pname = Process.GetProcessesByName(processName);
if (pname.Length == 0)
VA.SetBoolean("ProcessCheckResult", false);
else
VA.SetBoolean("ProcessCheckResult", true);
//if (pname.Length == 0)
//VA.WriteToLog("Process doesn't exist", "red");
//else
//VA.WriteToLog("Process is running", "green");
}
}
// References:
// https://stackoverflow.com/questions/262280/how-can-i-know-if-a-process-is-running
I've included some code lines in the inline function (commented out) if you just want to output the result to the event log while minimizing the VoiceAttack command actions. I've also provided the above content in the attached profile.
I've found that the "ProcessToCheck" value needs to be the executable name (without the .exe). So for the above example we're looking for the Microsoft Paint application. If you load Paint, open up the Task Manager, and search for Paint's Image Name you'll find it listed as "mspaint.exe." So as the above sample shows the "ProcessToCheck" would be "mspaint". I've also found that the "ProcessToCheck" value does not appear to be case sensitive.
Cheers!