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
Cycle Right Through 1/3 Sections
Return to DisplayFusion Scripted Functions (Macros)
Description
This script will size the window to 1/3 of the screen and cycle right through each section of the screen.
Language
C#.net
Minimum Version
9.4.3+
Created By
Keith Lammers (BFS)
Contributors
-
Date Created
Feb 21, 2019
Date Last Modified
Feb 21, 2019
Scripted Function (Macro) Code
Copy
Select All
using System; using System.Drawing; public static class DisplayFusionFunction { public static void Run(IntPtr windowHandle) { // Specify the number of sections to divide the monitor into here int numberOfSections = 3; // Setup the sections Rectangle[] sections = GetSections(numberOfSections, BFS.Monitor.GetMonitorIDByWindow(windowHandle)); // Check where the window currently is, then move it appropriately foreach (Rectangle section in sections) { // Check if the window is in this section if (BFS.Window.GetBounds(windowHandle) == section) { // Get the next section index int nextSection; if (Array.IndexOf(sections, section) < sections.GetUpperBound(0)) { nextSection = Array.IndexOf(sections, section) + 1; } else { // Get the next monitor ID uint[] monitorIDs = BFS.Monitor.GetMonitorIDs(); uint nextMonitorID; if (Array.IndexOf(monitorIDs, BFS.Monitor.GetMonitorIDByWindow(windowHandle)) < monitorIDs.GetUpperBound(0)) { nextMonitorID = monitorIDs[Array.IndexOf(monitorIDs, BFS.Monitor.GetMonitorIDByWindow(windowHandle)) + 1]; } else { nextMonitorID = monitorIDs[0]; } sections = GetSections(numberOfSections, nextMonitorID); nextSection = 0; } // Move the window to the next section BFS.Window.SetSizeAndLocation(windowHandle, sections[nextSection].X, sections[nextSection].Y, sections[nextSection].Width, sections[nextSection].Height); // Exit the script return; } else { // Check the window against the next section continue; } } // If we get here, the window wasn't in any of the sections, so move it to the next monitor BFS.Window.SetSizeAndLocation(windowHandle, sections[0].X, sections[0].Y, sections[0].Width, sections[0].Height); } private static Rectangle[] GetSections(int numberOfSections, uint monitorID) { Rectangle monitorWorkArea = BFS.Monitor.GetMonitorWorkAreaByID(monitorID); Rectangle section1 = new Rectangle(monitorWorkArea.X, monitorWorkArea.Y, monitorWorkArea.Width / numberOfSections, monitorWorkArea.Height); Rectangle section2 = new Rectangle(monitorWorkArea.X + monitorWorkArea.Width / numberOfSections, monitorWorkArea.Y, monitorWorkArea.Width / numberOfSections, monitorWorkArea.Height); Rectangle section3 = new Rectangle(monitorWorkArea.X + ((monitorWorkArea.Width / numberOfSections) * 2), monitorWorkArea.Y, monitorWorkArea.Width / numberOfSections, monitorWorkArea.Height); Rectangle[] sections = { section1, section2, section3 }; return sections; } }