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
Move Window to Left Side at 66% (Toggle)
Return to DisplayFusion Scripted Functions (Macros)
Description
This script will move the window to the left side of the screen and size it to 66% width. If it's already there, it will move it back to its original location.
Language
C#.net
Minimum Version
9.3+
Created By
Keith Lammers (BFS)
Contributors
-
Date Created
Dec 13, 2018
Date Last Modified
Dec 13, 2018
Scripted Function (Macro) Code
Copy
Select All
using System; using System.Drawing; public static class DisplayFusionFunction { public static void Run(IntPtr windowHandle) { // Get the window's current bounds Rectangle currentWindowBounds = BFS.Window.GetBounds(windowHandle); // Set the window width percentage here decimal windowWidthPercent = 0.66m; // Get the monitor bounds Rectangle monitorBounds = BFS.Monitor.GetMonitorWorkAreaByWindow(windowHandle); // Create the target window bounds Rectangle targetWindowBounds = new Rectangle(); // Set the target window width to the screen width * the windowWidthPercent targetWindowBounds.Width = Convert.ToInt32(monitorBounds.Width * windowWidthPercent); // Set the target window height to 100% of the screen height targetWindowBounds.Height = monitorBounds.Height; // Set the target X value to the left side of the monitor targetWindowBounds.X = monitorBounds.X; // Set the target Y value to the top side of the monitor targetWindowBounds.Y = monitorBounds.Y; // Move the window to the target location or back to its original location if ((currentWindowBounds.X <= (targetWindowBounds.X - 15) || (currentWindowBounds.X >= (targetWindowBounds.X - 15))) && (currentWindowBounds.Y <= (targetWindowBounds.Y - 15) || (currentWindowBounds.Y >= (targetWindowBounds.Y - 15))) && currentWindowBounds.Width == targetWindowBounds.Width && currentWindowBounds.Height == targetWindowBounds.Height) { // Move it to its original location BFS.Window.SetSizeAndLocation(windowHandle, Convert.ToInt32(BFS.ScriptSettings.ReadValue(windowHandle.ToString("X8") + "_X")), Convert.ToInt32(BFS.ScriptSettings.ReadValue(windowHandle.ToString("X8") + "_Y")), Convert.ToInt32(BFS.ScriptSettings.ReadValue(windowHandle.ToString("X8") + "_Width")), Convert.ToInt32(BFS.ScriptSettings.ReadValue(windowHandle.ToString("X8") + "_Height"))); // Clear the previously saved bounds BFS.ScriptSettings.DeleteValue(windowHandle.ToString("X8") + "_X"); BFS.ScriptSettings.DeleteValue(windowHandle.ToString("X8") + "_Y"); BFS.ScriptSettings.DeleteValue(windowHandle.ToString("X8") + "_Width"); BFS.ScriptSettings.DeleteValue(windowHandle.ToString("X8") + "_Height"); } else { // Save the window's current bounds BFS.ScriptSettings.WriteValue(windowHandle.ToString("X8") + "_X", currentWindowBounds.X.ToString()); BFS.ScriptSettings.WriteValue(windowHandle.ToString("X8") + "_Y", currentWindowBounds.Y.ToString()); BFS.ScriptSettings.WriteValue(windowHandle.ToString("X8") + "_Width", currentWindowBounds.Width.ToString()); BFS.ScriptSettings.WriteValue(windowHandle.ToString("X8") + "_Height", currentWindowBounds.Height.ToString()); // Move the window to the target location BFS.Window.SetSizeAndLocation(windowHandle, targetWindowBounds.X, targetWindowBounds.Y, targetWindowBounds.Width, targetWindowBounds.Height); } // Clean up saved bounds for windows that no longer exist foreach (string valueName in BFS.ScriptSettings.GetValueNames()) { IntPtr[] windowHandles = BFS.Window.GetVisibleAndMinimizedWindowHandles(); bool windowStillExists = false; foreach (IntPtr window in windowHandles) { if (valueName.Contains(window.ToString("X8"))) { windowStillExists = true; } } if (!windowStillExists) { BFS.ScriptSettings.DeleteValue(valueName); } } } }