using System; using System.Drawing; // The 'windowHandle' parameter will contain the window handle for the: // - Active window when run by hotkey // - Trigger target when run by a Trigger rule // - TitleBar Button owner when run by a TitleBar Button // - Jump List owner when run from a Taskbar Jump List // - Currently focused window if none of these match public static class DisplayFusionFunction { public static void Run(IntPtr windowHandle) { ///////////////////////////////////////////////////////////////////////////////////////////// //NOTE: Change these paths with the paths to the programs you want to start in each monitor// ///////////////////////////////////////////////////////////////////////////////////////////// //the @ automatically escapes the backslashes, making things like paths a lot easier to work with //the programs in this list will open from left to right string[] paths = new string[] { @"C:\Windows\NotePad.exe", @"C:\Windows\NotePad.exe", @"C:\Windows\NotePad.exe", @"C:\Windows\NotePad.exe", @"C:\Windows\NotePad.exe", @"C:\Windows\NotePad.exe", }; //a variable to keep track of the current app we are opening int currentPath = 0; //loop through all monitors foreach(uint monitorId in BFS.Monitor.GetMonitorIDs()) { //start up a path from the list and grab it's application id uint pid = BFS.Application.Start(paths[currentPath++ % paths.Length], ""); //wait for the application to start up while(!BFS.Application.IsAppRunningByAppID(pid)) BFS.General.ThreadWait(100); //grab the main window for the application IntPtr window = BFS.Application.GetMainWindowByAppID(pid); //if we couldn't get the window for the app, continue to the next one if(window == IntPtr.Zero) continue; //move the window to the right monitor BFS.Window.MoveToMonitor(monitorId, window); } } }