Binary Fortress
Binary Fortress Software
CheckCentral
ClipboardFusion
CloudShow
CloudShow Manager
DisplayFusion
FileSeek
HashTools
LogFusion
Notepad Replacer
Online Base64 Decoder
Online Base64 Encoder
Online JSON Formatter
ShellSend
TrayStatus
VoiceBot
WallpaperFusion
Window Inspector
More Apps...
DisplayFusion
CheckCentral
CloudShow
ClipboardFusion
FileSeek
TrayStatus
VoiceBot
WallpaperFusion
Display
Fusion
by Binary Fortress Software
Download
Download
Change Log
Download Beta
Beta Change Log
License (EULA)
Features
Free vs Pro
More
Screenshots
Scripted Functions (Macros)
Languages
Help
Help Guide
FAQ
Discussions
Contact Us
Find My License
Mailing Address
Advanced Settings
Purchase
Login / Register
WARNING: You currently have Javascript disabled!
This website will not function correctly without Javascript enabled.
Title
Message
OK
Confirm
Yes
No
Swap All Windows Between Monitors 1 and 2
Return to DisplayFusion Scripted Functions (Macros)
Description
This script will swap all open windows between monitors 1 and 2.
Language
C#.net
Minimum Version
8.1.2+
Created By
Keith Lammers (BFS)
Contributors
-
Date Created
Feb 24, 2017
Date Last Modified
Dec 14, 2018
Scripted Function (Macro) Code
Copy
Select All
using System; using System.Drawing; using System.Windows.Forms; public static class DisplayFusionFunction { public static void Run(IntPtr windowHandle) { // set the monitor IDs of the monitors you want to swap here uint monitorA = 1; uint monitorB = 2; //if the passed window handle doesn't exist, exit the function if (windowHandle == IntPtr.Zero) return; //get the open windows for each monitor IntPtr[] srcWindowsMonitor2 = BFS.Window.GetVisibleWindowHandlesByMonitor(monitorB); IntPtr[] srcWindowsMonitor1 = BFS.Window.GetVisibleWindowHandlesByMonitor(monitorA); //move all of the windows in the destination monitor to the source monitor foreach (IntPtr window in srcWindowsMonitor2) { if (BFS.Window.GetText(window).Contains("Chrome")) { BFS.Window.Restore(window); BFS.Window.MoveToMonitor(monitorA, window); BFS.Window.Maximize(window); } BFS.Window.MoveToMonitor(monitorA, window); } BFS.General.ThreadWait(1000); //move all of the windows in the source monitor to the destination monitor foreach (IntPtr window in srcWindowsMonitor1) { if (BFS.Window.GetText(window).Contains("Chrome")) { BFS.Window.Restore(window); BFS.Window.MoveToMonitor(monitorB, window); BFS.Window.Maximize(window); } BFS.Window.MoveToMonitor(monitorB, window); } } }