Processing Ajax...

Close Dialog


Close Dialog

Close Dialog

A recent AVG and Avast antivirus update is preventing DisplayFusion 9.9 from launching on some systems.
If you're running into this issue, please update to the latest DisplayFusion 10.0 Beta.

Cascade Windows on Current Monitor

This script will cascade all of the windows on the current monitor.
Minimum Version
Created By
Keith Lammers (BFS)
Date Created
Apr 9, 2020
Date Last Modified
Apr 9, 2020

Scripted Function (Macro) Code

using System;
using System.Drawing;

public static class DisplayFusionFunction
	public static void Run(IntPtr windowHandle)
        // Get the current monitor ID
        uint monitorID = BFS.Monitor.GetMonitorIDByXY(BFS.Input.GetMousePositionX(), BFS.Input.GetMousePositionY());
        // Get all visible and minimized windows
		IntPtr[] windows = BFS.Window.GetVisibleAndMinimizedWindowHandles();
        // Get the monitor bounds
        Rectangle monitorBounds = BFS.Monitor.GetMonitorBoundsByID(monitorID);

		// Set the starting position for the first window in the cascade
		int x = monitorBounds.X;
		int y = monitorBounds.Y;
		// Loop through the windows, if they're on the current monitor, cascade them
		foreach (IntPtr window in windows)
            if (BFS.Monitor.GetMonitorIDByWindow(window) == monitorID)
                // Ignore windows that have a blank window title
                if (!(BFS.Window.GetText(window) == ""))
                    // Move the window and size it to 75% width/height
                    BFS.Window.SetSizeAndLocation(window, x, y, Convert.ToInt32(monitorBounds.Width * 0.75), Convert.ToInt32(monitorBounds.Height * 0.75));
                    // Increment the x,y values for the next window in the loop
                    x = x + 10;
                    y = y + 10;