Processing Ajax...

Title

Message

Confirm

Confirm

Confirm

Confirm

Are you sure you want to delete this item?

Confirm

Are you sure you want to delete this item?

Confirm

Are you sure?

Move all windows from monitor #3 to monitor #2

Description
This script will move all windows from monitor 3 to monitor 2.
Language
C#.net
Minimum Version
Created By
Anoka84423
Contributors
-
Date Created
Dec 19, 2025
Date Last Modified
Dec 19, 2025

Scripted Function (Macro) Code

using System;
using System.Drawing;

public static class DisplayFusionFunction
{
	public static void Run(IntPtr windowHandle)
	{
		// Set the Monitor ID you want to move the windows from
		uint sourceMonitorID = 3;

		// Set the target monitor ID here
		uint targetMonitorID = 2;

		// Loop through the visible windows on the monitor and move them to the monitor that has the mouse cursor
		foreach (IntPtr window in BFS.Window.GetVisibleWindowHandlesByMonitor(sourceMonitorID))
		{
			// If the window is minimized, move it to monitor 2 and minimize it
			if (BFS.Window.IsMinimized(window))
			{
				BFS.Window.MoveToMonitor(targetMonitorID, window);
				BFS.Window.Minimize(window);
			}
			// Otherwise, just move it to monitor 2
			else
			{
				BFS.Window.MoveToMonitor(targetMonitorID, window);
			}
		}
	}
}