{ "name": "Move applications to first available zone", "language": 0, "code": "using System;\r\nusing System.Drawing;\r\nusing System.Collections.Generic;\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 X, Y, Width, Height of the positions here\r\n\t\tList positions = new List();\r\n\t\tpositions.Add(new Rectangle(-1, 0, 963, 521));\r\n\t\tpositions.Add(new Rectangle(960, 0, 963, 521));\r\n\t\tpositions.Add(new Rectangle(-1, 521, 963, 521));\r\n\t\tpositions.Add(new Rectangle(960, 520, 963, 521));\r\n\t\tpositions.Add(new Rectangle(-964, 0, 963, 521));\r\n\t\tpositions.Add(new Rectangle(-1927, 0, 963, 521));\r\n\t\tpositions.Add(new Rectangle(-964, 520, 963, 521));\r\n\t\tpositions.Add(new Rectangle(-1927, 520, 963, 521));\r\n\t\t\r\n\t\t// Set the process name of the application here\r\n\t\tString[] processNames = {\"notepad.exe\",\"notepad++.exe\"};\r\n\t\t\r\n\t\t// Check if there are any open windows at either position\r\n\t\tbool[] positionsOccupied = new bool[positions.Count];\r\n\t\tfor (int i = 0; i < positions.Count; i++)\t\t\r\n\t\t{\r\n\t\t\tpositionsOccupied[i] = false;\r\n\t\t}\r\n\t\t\r\n\t\tforeach (IntPtr window in BFS.Window.GetVisibleWindowHandles())\r\n\t\t{\r\n\t\t\tint j = 0;\r\n\t\t\tforeach (Rectangle position in positions)\r\n\t\t\t{\r\n\t\t\t\tforeach (String processName in processNames)\r\n\t\t\t\t{\r\n\t\t if (BFS.Application.GetMainFileByWindow(window).ToLower().Contains(processName.ToLower()))\r\n\t\t {\r\n\t\t Rectangle bounds = BFS.Window.GetBounds(window);\r\n\t\t\t\t\t\tif (bounds == position)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tpositionsOccupied[j] = true;\r\n\t\t\t\t\t\t}\r\n\t\t }\r\n\t\t\t\t}\r\n\t\t\tj++;\r\n\t\t\t}\r\n\t\t}\r\n\t\t\r\n\t\t// Place the new window depending on where the open ones are\r\n\t\tint k = 0;\r\n\t\tforeach (bool positionOccupied in positionsOccupied)\r\n\t\t{\r\n\t\t\tif (!positionOccupied)\r\n\t\t\t{\r\n\t\t\t\tBFS.Window.SetSizeAndLocation(windowHandle, positions[k].X, positions[k].Y, positions[k].Width, positions[k].Height);\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t\tk++;\r\n\t\t}\r\n\t}\r\n}", "description": "Use this script in conjunction with a \"Window Created\" Trigger rule for the application you want it to affect. You'll need to configure the X, Y, Width, and Height of each zone in the \"positions\" list starting on line 17, and the process names of the applications on line 27.", "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" }