{ "name": "Move Window to Position According to Multiple Screen Topology", "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 // Set the distance from the top right corner, and the target monitor ID\r\n int topDistance = 30;\r\n int rightDistance = 30;\r\n int leftDistance = 30;\r\n uint targetMonitor = 2;\r\n int windowWidth = 340;\r\n int windowsHeight = 980;\r\n\t\r\n // Set window size\r\n BFS.Window.SetSize(windowHandle, windowWidth, windowsHeight);\r\n \r\n\t\t// Check if the target monitor is attached, if so move the window, if not position to default one\r\n\t\tif (BFS.Monitor.GetMonitorBoundsByID(targetMonitor).Width > 0)\r\n\t\t{\r\n // Get the target monitor bounds and the window bounds\r\n Rectangle targetMonitorBounds = BFS.Monitor.GetMonitorBoundsByID(2);\r\n Rectangle windowBounds = BFS.Window.GetBounds(windowHandle);\r\n \r\n // Calculate the X location and set the Y location\r\n int x = (targetMonitorBounds.X + leftDistance);\r\n int y = topDistance;\r\n\r\n // Move the window\r\n BFS.Window.SetLocation(windowHandle, x, y);\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n // Get the target monitor bounds and the window bounds\r\n Rectangle targetMonitorBounds = BFS.Monitor.GetMonitorBoundsByID(1);\r\n Rectangle windowBounds = BFS.Window.GetBounds(windowHandle);\r\n \r\n // Calculate the X location and set the Y location\r\n int x = (targetMonitorBounds.X + targetMonitorBounds.Width) - (windowBounds.Width + rightDistance);\r\n int y = topDistance;\r\n\r\n // Move the window\r\n BFS.Window.SetLocation(windowHandle, x, y);\r\n\t\t}\r\n\t}\r\n}", "description": "", "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" }