{ "name": "Minimize All Windows and Restore Them After the Mouse Moves", "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// Get the mouse position at the time the script started\r\n\t\tPoint scriptStartMousePosition = new Point(BFS.Input.GetMousePositionX(),BFS.Input.GetMousePositionY());\r\n\t\t\r\n\t\t// Minimize all windows with Win + D\r\n\t\tBFS.Input.SendKeys(\"{WIN}({VK_68})\");\r\n\t\t\r\n\t\t// Loop every second to see if the mouse has moved since the script started\r\n\t\twhile (true)\r\n\t\t{\r\n\t\t\tPoint currentMousePosition = new Point(BFS.Input.GetMousePositionX(),BFS.Input.GetMousePositionY()); // Gets the current mouse position\r\n\t\t\t\r\n\t\t\tif (scriptStartMousePosition != currentMousePosition) // Checks if it's different than when the script started\r\n\t\t\t{\r\n\t\t\t\tBFS.General.ThreadWait(1000);\r\n\t\t\t\tbreak; // If so, breaks out of the loop\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\tBFS.General.ThreadWait(1000); // 1 second wait to prevent loop from running up the CPU\r\n\t\t}\r\n\t\t\r\n\t\t// When the loop breaks because the mouse moved, restore all windows with Win+D and exit the script\r\n\t\tBFS.Input.SendKeys(\"{WIN}({VK_68})\");\r\n\t}\r\n}", "description": "This script will run Win+D (Show Desktop) to minimize all windows when it starts, and then if the mouse is moved, it will run Win+D again to restore the windows.", "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" }