Login / Register
▼
Binary Fortress
Binary Fortress Software
ASP.NET ViewState Helper
CheckCentral
ClipboardFusion
CloudShow
DisplayFusion
FileSeek
HashTools
iTunesFusion
JigsawMania
LogFusion
Notepad Replacer
Online Base64 Encoder
Online JSON Formatter
ShellSend
TrayStatus
VoiceBot
WallpaperFusion
Window Inspector
More Apps...
DisplayFusion
CheckCentral
CloudShow
ClipboardFusion
FileSeek
VoiceBot
WallpaperFusion
Home
▼
Download
Download
Change Log
Download Beta
Beta Change Log
License (EULA)
▼
Features
Features
Incredible Desktop Wallpaper
Precise Monitor Controls
Powerful Functions
Triggers
Multi-Monitor Taskbars
Useful Windows 10 Tweaks
Useful Windows 8 Tweaks
Windows Lock Screen
Multi-Monitor Screen Savers
Monitor Fading
Window Snapping
Window Management
Mouse Management
Alt+Tab Handler
Window Position Profiles
Desktop Icon Profiles
Remote Control
Available in dozens of Languages
Easy Administration
Free vs Pro
Purchase
Screenshots
Languages
▼
Help
Help Guide
FAQ
Discussions
Contact Us
Find My License
Mailing Address
Advanced Settings
Scripted Functions (Macros)
DisplayFusion
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#
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
Toggle Line Wrapping
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); } } }
Copyright © 2007-2019 Binary Fortress Software
•
News
•
Discussions
•
FAQ
•
Support
•
Privacy
•
ToS
•
Get DisplayFusion Merch