{ "name": "Check if application is running and maximized", "language": 0, "code": "using System;\r\nusing System.Drawing;\r\n\r\n// The 'windowHandle' parameter will contain the window handle for the:\r\n// - Active window when run by hotkey\r\n// - Trigger target when run by a Trigger rule\r\n// - TitleBar Button owner when run by a TitleBar Button\r\n// - Jump List owner when run from a Taskbar Jump List\r\n// - Currently focused window if none of these match\r\npublic static class DisplayFusionFunction\r\n{\r\n\tpublic static void Run(IntPtr windowHandle)\r\n\t{\r\n\t\t// Set the process name here (leave the asterisk at the start)\r\n string processName = \"*notepad.exe\";\r\n \r\n // Set the full path to the process here\r\n string processFullPath = @\"notepad.exe\";\r\n \r\n // Check if the app is running\r\n bool isAppRunning = BFS.Application.IsAppRunningByFile(processName);\r\n \r\n // If the app isn't running, start it\r\n if (!isAppRunning)\r\n {\r\n BFS.Application.Start(processFullPath, \"\");\r\n BFS.General.ThreadWait(2000);\r\n }\r\n \r\n // Get window handle \r\n IntPtr window = BFS.Application.GetMainWindowByFile(\"*notepad.exe*\");\r\n \r\n // Check if app is maximized\r\n bool isAppMaximized = BFS.Window.IsMaximized(window); \r\n \r\n // If it is maximized and wasn't just launched, minimize it\r\n if (isAppMaximized && isAppRunning)\r\n {\r\n BFS.Window.Minimize(window);\r\n }\r\n\r\n else if (BFS.Window.IsMinimized(window))\r\n {\r\n BFS.Window.Restore(window); \r\n } \r\n \r\n // If it's not maximized, then maximize it\r\n else if (!isAppMaximized)\r\n {\r\n BFS.Window.Maximize(window);\r\n }\r\n\t}\r\n}", "description": "This script will check if the specified application is running, and launch it if it's not. It will also maximize the application if it's not already, and minimize it, if it's already maximized.", "references": "System.Core.dll|System.Data.dll|System.dll|System.Drawing.dll|System.Management.dll|System.Web.dll|System.Windows.Forms.dll|System.Xml.dll" }