using System;
using System.Drawing;
public static class DisplayFusionFunction
{
public static void Run(IntPtr windowHandle)
{
// Set the process name here (case sensitive)
string processName = "*notepad++.exe";
// Set the process checking timeout (in milliseconds) here
uint processCheckWaitTime = 10000;
// Set the "cooldown" timeout (in milliseconds) here
uint cooldownTime = 30000;
// Loop forever looking for the process
while (true)
{
// DEBUG
BFS.General.LogText("Script: \"Do stuff on process start/end\" main loop starting (process exists check)...");
// If it's found do stuff
if (BFS.Application.IsAppRunningByFile(processName))
{
BFS.General.LogText("Script: \"Do stuff on process start/end\" found process...");
// Wait 30 seconds to make sure it's still around
// This prevents these actions from firing multiple times if the process closes/re-opens quickly
BFS.General.ThreadWait(cooldownTime);
if (BFS.Application.IsAppRunningByFile(processName))
{
BFS.General.LogText("Script: \"Do stuff on process start/end\" process still found, doing the process started stuff...");
// Stuff you want to do when the process has started
BFS.DisplayFusion.RunFunctionAndWait("Function Name");
// Now periodically check if it's still running, then do stuff when it's not
while (true)
{
BFS.General.LogText("Script: \"Do stuff on process start/end\" process gone loop starting...");
if (!BFS.Application.IsAppRunningByFile(processName))
{
// Wait 30 seconds to make sure it's gone for good
BFS.General.ThreadWait(cooldownTime);
if (!BFS.Application.IsAppRunningByFile(processName))
{
BFS.General.LogText("Script: \"Do stuff on process start/end\" process still gone, doing stuff...");
// Stuff you want to do when the process has ended
BFS.DisplayFusion.RunFunctionAndWait("Function name");
// Exit the process ended check loop
break;
}
}
else
{
// Wait 10 seconds before restarting the process ended loop
BFS.General.ThreadWait(processCheckWaitTime);
}
}
}
}
// Wait 10 seconds before restarting the process started loop
BFS.General.ThreadWait(processCheckWaitTime);
}
}
}