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.

Apply Snap

Windows 10 has an irritating behaviour of making non maximized windows stand-off from monitor edges. This script works around that behaviour by snapping the window back to the edges if it's close to them. Assign to a "Window Created" trigger.
Minimum Version
Created By
Alex Vallat75938
Date Created
Nov 18, 2019
Date Last Modified
Jul 19, 2021

Scripted Function (Macro) Code

using System;
using System.Drawing;

// 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
public static class DisplayFusionFunction
    private const int SnapDistance = 10;
	public static void Run(IntPtr windowHandle)
		var windowBounds = BFS.Window.GetBounds(windowHandle);
		var monitorBounds = BFS.Monitor.GetMonitorWorkAreaByWindow(windowHandle);
		var left = SnapTo(windowBounds.Left, monitorBounds.Left);
		var right = SnapTo(windowBounds.Right, monitorBounds.Right);
		var top = SnapTo(windowBounds.Top, monitorBounds.Top);
		var bottom = SnapTo(windowBounds.Bottom, monitorBounds.Bottom);
		BFS.Window.SetSizeAndLocation(windowHandle, left, top, right - left, bottom - top);
    private static int SnapTo(int value, int snapTo)
        return (Math.Abs(snapTo - value) < SnapDistance) ? snapTo : value;