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.

Rollup window when not in focus

This script will roll up the specified window when not in focus. Set the window text you want to look for on line 15.
Minimum Version
Created By
Keith Lammers (BFS)
Date Created
Jul 2, 2021
Date Last Modified
Jul 2, 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
	public static void Run(IntPtr windowHandle)
        // Set part of the Window Text to look for in the window title here
        string targetWindowText = "*Notepad*";
        // Loop forever
		while (true)
            // Get the focused window and the target window
            IntPtr focusedWindow = BFS.Window.GetFocusedWindow();
            IntPtr targetWindow = BFS.Window.GetWindowByText(targetWindowText);
            // If the target window isn't focused and isn't already rolled up, roll it up
            if (focusedWindow != targetWindow && !BFS.Window.IsWindowRolledUpToIcon(targetWindow))
            // Wait 250ms before looping to avoid running up the CPU