Processing Ajax...

Title
Close Dialog

Message

Confirm
Close Dialog

Confirm
Close Dialog

Move All Windows to Primary Monitor

Description
This script will move all open windows to the Primary monitor.
Language
C#.net
Minimum Version
Created By
Keith Lammers (BFS)
Contributors
-
Date Created
Sep 25, 2018
Date Last Modified
Oct 2, 2018

Scripted Function (Macro) Code

using System;
using System.Drawing;

public static class DisplayFusionFunction
{
	public static void Run(IntPtr windowHandle)
	{
        // Get the Primary monitor's ID
        uint primaryMonitor = BFS.Monitor.GetPrimaryMonitorID();
        
        // Loop through all monitors
		foreach (uint monitor in BFS.Monitor.GetMonitorIDs())
		{
            // Ignore the Primary monitor
            if (primaryMonitor != monitor)
            {
                // Loop through all windows on the monitor and move them to the Primary monitor
                foreach (IntPtr window in BFS.Window.GetVisibleAndMinimizedWindowHandles())
                {
                    if (BFS.Monitor.GetMonitorIDByWindow(window) != primaryMonitor)
                        BFS.Window.MoveToMonitor(primaryMonitor, window);
                }
            }
            
        }
	}
}