Login / Register
▼
Binary Fortress
Binary Fortress Software
CheckCentral
ClipboardFusion
CloudShow
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
VoiceBot
WallpaperFusion
Home
▼
Download
Download
Change Log
Download Beta
Beta Change Log
License (EULA)
▼
Features
Features
Incredible Desktop Wallpaper
Monitor Configuration
Monitor Splitting
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)
Display
Fusion
WARNING: You currently have Javascript disabled!
This website will not function correctly without Javascript enabled.
Title
Message
OK
Confirm
Yes
No
Move Window to Monitor on the Right and Maximize It
Return to DisplayFusion Scripted Functions (Macros)
Description
This function looks at physical monitor position (just X axis) and transfers window on first monitor on the RIGHT.
Language
C# (.Net)
Minimum Version
8.0+
Created By
Antonio Bakula
Contributors
-
Date Created
Oct 28, 2016
Date Last Modified
Oct 28, 2016
Scripted Function (Macro) Code
Copy
Select All
Toggle Line Wrapping
using System; using System.Collections.Generic; using System.Drawing; using System.Linq; // 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 // This function looks at physical monitor position (just X axis) and transfers window on first monitor on the RIGHT // Monitors setup on my Laptop when docked //+-------------------------+ +-------------------------+ //| | | | //| | | | //| Monitor 2 (1680x1050) | | Monitor 3 (1680x1050) | //| | | | //| | | | //| | | | //+-------------------------+ +-------------------------+ // +------------------------------+ // | | // | | // | Monitor 1 (1920x1080) | // | | // | | // | | // +------------------------------+ // when invoked on monitor 1 it will transfer window on monitor 3 // when invoked on monitor 2 it will transfer window on monitor 1 // when invoked on monitor 3 it will transfer window on monitor 2 public static class DisplayFusionFunction { public static void Run(IntPtr windowHandle) { var mhor = new MonitorsHorizontalOrder(); uint handleMonitor = BFS.Monitor.GetMonitorIDByWindow(windowHandle); uint targetMonitor = mhor.GetMonitorOnTheRight(handleMonitor); if (handleMonitor != targetMonitor) { BFS.Window.MoveToMonitorMaximized(targetMonitor, windowHandle); } } [Serializable] public class WindowBoundsInfo { public uint MonitorID { get; set; } public Rectangle Bounds { get; set; } public WindowBoundsInfo(uint monID) { this.Bounds = BFS.Monitor.GetMonitorBoundsByID(monID); this.MonitorID = monID; } } public class MonitorsHorizontalOrder { private List<WindowBoundsInfo> monitorOrderedBounds; public MonitorsHorizontalOrder() { var monitorIds = BFS.Monitor.GetMonitorIDs(); GetInfoAndOrderMonitorsHorizontally(monitorIds); } public MonitorsHorizontalOrder(IEnumerable<uint> monitorIds) { GetInfoAndOrderMonitorsHorizontally(monitorIds); } private void GetInfoAndOrderMonitorsHorizontally(IEnumerable<uint> monitorIds) { this.monitorOrderedBounds = monitorIds.Select(mid => new WindowBoundsInfo(mid)).OrderBy(wbi => wbi.Bounds.Left).ToList(); } public uint GetMonitorOnTheLeft(uint monID) { var index = GetMonitorIndexInList(monID); if (index.HasValue) { if (index.Value > 0) { return this.monitorOrderedBounds[index.Value - 1].MonitorID; } else { return this.monitorOrderedBounds.Last().MonitorID; } } // fail safe return monID; } public uint GetMonitorOnTheRight(uint monID) { var index = GetMonitorIndexInList(monID); if (index.HasValue) { if (index.Value == this.monitorOrderedBounds.Count-1) { return this.monitorOrderedBounds.First().MonitorID; } else { return this.monitorOrderedBounds[index.Value + 1].MonitorID; } } // default return monID; } private int? GetMonitorIndexInList(uint monID) { int? index = null; var currentInfo = this.monitorOrderedBounds.FirstOrDefault(wbi => wbi.MonitorID == monID); if (currentInfo != null) { index = this.monitorOrderedBounds.IndexOf(currentInfo); } return index; } } }
Copyright © 2007-2021 Binary Fortress Software
•
News
•
Discussions
•
FAQ
•
Support
•
Privacy
•
ToS
•
Get DisplayFusion Merch