Processing Ajax...

Title

Message

Confirm

Confirm

Confirm

Confirm

Are you sure you want to delete this item?

Confirm

Are you sure you want to delete this item?

User Image
BobbyTesla
1 discussion post
How can I minimize all windows on all monitors on Version 7?

Thanks,
Jan 5, 2015 (modified Jan 5, 2015)  • #1
Keith Lammers (BFS)'s profile on WallpaperFusion.com
There's a Scripted Function that can do this. Just go to Settings > Functions > Download Scripted, download the one called "Minimize/Restore All Windows," give it a hotkey, and you're all set :)

Hope that helps!
Jan 6, 2015  • #2
User Image
Retko
13 discussion posts
Hi, the scripting function dont work correctly. It makes my taskbar on secondary monitor to crash and reopen. And this minimizing is kinda slow (when work and dont make taskbar crash). Can you please fix it?

I dont want to use WIN+D, since I often disable WIN button.

Let me know if you need something. Thank you.

Here is code i use:

```

using System;
using System.Drawing;
using System.Collections.Generic;
using System.Text;

// The 'windowHandle' parameter will contain the window handle for the:
// - Active window when run by hotkey
// - Window Location target when run by a Window Location 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
{
//an enum to set the script state
private enum ScriptState
{
Normal = 0,
Minimized = 1
}

public static void Run(IntPtr windowHandle)
{
//constants to set and get the window state property
const string windowStateProperty = "MinimizeAndRestoreWindows_WindowState";

//random values to use as property values
const int normalState = 432985;
const int maximizedState = 347561;

//if the script is in it's minimized state, restore the saved window positions
if(IsScriptInMinimizeState())
{
//loop over every window
foreach(IntPtr window in BFS.Window.GetAllWindowHandles())
{
//check for a saved property
IntPtr windowState = BFS.Window.GetWindowProperty(window, windowStateProperty);

//if we couldnt find a property, continue to the next window
if(windowState == IntPtr.Zero)
continue;

//if the window was in a normal state, restore it
if(windowState.ToInt64() == normalState)
BFS.Window.Restore(window);

//if the window was in a maximized state, maximize it
if(windowState.ToInt64() == maximizedState)
BFS.Window.Maximize(window);

//remove the property from the window
BFS.Window.RemoveWindowProperty(window, windowStateProperty);
}

//reset the script state
SetScriptState(ScriptState.Normal);

//exit the script
return;
}

//if we got to this point we should save all of the windows, then minimize them
//loop through all of the visiable windows, save their state, then minimize then
foreach(IntPtr window in BFS.Window.GetVisibleWindowHandles())
{
if(BFS.Window.IsMaximized(window))
BFS.Window.SetWindowProperty(window, windowStateProperty, new IntPtr(maximizedState));

if(BFS.Window.IsRestored(window))
BFS.Window.SetWindowProperty(window, windowStateProperty, new IntPtr(normalState));

BFS.Window.Minimize(window);
}

//set the script state to minimized
SetScriptState(ScriptState.Minimized);
}

//this function quickly checks to see whether we need to restore previously minimized windows
private static bool IsScriptInMinimizeState()
{
//read the setting value
string state = BFS.ScriptSettings.ReadValue("Minimize and Restore Windows State");

//return the saved state. if no state saved, return false
return (state.Length != 0) && (state.Equals("minimized"));
}

//this function saves the script state
private static void SetScriptState(ScriptState state)
{
//save the state
BFS.ScriptSettings.WriteValue("Minimize and Restore Windows State", (state == ScriptState.Normal) ? "normal" : "minimized");
}
}

```
Sep 2, 2024 (modified Sep 2, 2024)  • #3
Keith Lammers (BFS)'s profile on WallpaperFusion.com
I'll take a look at it next week and see what I can find out.

Thanks!
Sep 6, 2024  • #4
Keith Lammers (BFS)'s profile on WallpaperFusion.com
Had some time today actually. Could you give this code a try?

Code

using System;
using System.Drawing;
using System.Collections.Generic;
using System.Text;

// The 'windowHandle' parameter will contain the window handle for the:
// - Active window when run by hotkey
// - Window Location target when run by a Window Location 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
{
    //an enum to set the script state
    private enum ScriptState
    {
        Normal = 0,
Minimized = 1
    }

    public static void Run(IntPtr windowHandle)
    {
        //constants to set and get the window state property
        const string windowStateProperty = "MinimizeAndRestoreWindows_WindowState";

        //random values to use as property values
        const int normalState = 432985;
        const int maximizedState = 347561;

        //if the script is in it's minimized state, restore the saved window positions
        if (IsScriptInMinimizeState())
        {
            //loop over every window
            foreach (IntPtr window in BFS.Window.GetAllWindowHandles())
            {
                // Skip DisplayFusion windows and hidden explorer windows
                if(IsDisplayFusionWindowOrHiddenExplorerWindow(window))
                    continue;
                
                //check for a saved property
                IntPtr windowState = BFS.Window.GetWindowProperty(window, windowStateProperty);

                //if we couldnt find a property, continue to the next window
                if (windowState == IntPtr.Zero)
                    continue ;

                //if the window was in a normal state, restore it
                if (windowState.ToInt64() == normalState)
                    BFS.Window.Restore(window);

                //if the window was in a maximized state, maximize it
                if (windowState.ToInt64() == maximizedState)
                    BFS.Window.Maximize(window);

                //remove the property from the window
                BFS.Window.RemoveWindowProperty(window, windowStateProperty);
            }

            //reset the script state
            SetScriptState(ScriptState.Normal);

            //exit the script
            return;
        }

        //if we got to this point we should save all of the windows, then minimize them
        //loop through all of the visiable windows, save their state, then minimize then
        foreach (IntPtr window in BFS.Window.GetVisibleWindowHandles())
        {
            // Skip DisplayFusion windows and hidden explorer windows
            if(IsDisplayFusionWindowOrHiddenExplorerWindow(window))
                continue;
            
            if (BFS.Window.IsMaximized(window))
                BFS.Window.SetWindowProperty(window, windowStateProperty, new IntPtr(maximizedState));

            if (BFS.Window.IsRestored(window))
                BFS.Window.SetWindowProperty(window, windowStateProperty, new IntPtr(normalState));

            BFS.Window.Minimize(window);
        }

        //set the script state to minimized
        SetScriptState(ScriptState.Minimized);
    }

    //this function quickly checks to see whether we need to restore previously minimized windows
    private static bool IsScriptInMinimizeState()
    {
        //read the setting value
        string state = BFS.ScriptSettings.ReadValue("Minimize and Restore Windows State");

        //return the saved state. if no state saved, return false
        return (state.Length != 0) && (state.Equals("minimized"));
    }

    //this function saves the script state
    private static void SetScriptState(ScriptState state)
    {
        //save the state
        BFS.ScriptSettings.WriteValue("Minimize and Restore Windows State", (state == ScriptState.Normal) ? "normal" : "minimized");
    }
    
    private static bool IsDisplayFusionWindowOrHiddenExplorerWindow(IntPtr window)
    {
        // Ignore any DisplayFusion windows (title bar buttons, etc.)
        // Ignore pesky hidden explorer.exe windows
        string windowClass = BFS.Window.GetClass(window);
        if((windowClass.StartsWith("DF", StringComparison.OrdinalIgnoreCase)) ||
            (windowClass.Equals("EdgeUiInputTopWndClass", StringComparison.OrdinalIgnoreCase)) ||
            (windowClass.Equals("EdgeUiInputWndClass", StringComparison.OrdinalIgnoreCase)) ||
            (windowClass.Equals("NativeHWNDHost", StringComparison.OrdinalIgnoreCase)) ||
            (windowClass.Equals("ModeInputWnd", StringComparison.OrdinalIgnoreCase)) ||
            (windowClass.Equals("MetroGhostWindow", StringComparison.OrdinalIgnoreCase)) ||
            (windowClass.Equals("ImmersiveLauncher", StringComparison.OrdinalIgnoreCase)) ||
            (windowClass.Equals("ApplicationManager_ImmersiveShellWindow", StringComparison.OrdinalIgnoreCase)) ||
            (windowClass.Equals("Shell_TrayWnd", StringComparison.OrdinalIgnoreCase)) ||
            (windowClass.Equals("WorkerW", StringComparison.OrdinalIgnoreCase)) ||
            (windowClass.Equals("Progman", StringComparison.OrdinalIgnoreCase)) ||
            (windowClass.Equals("SearchPane", StringComparison.OrdinalIgnoreCase)))
        {
            return true;
        }
        
        return false;
    }
}
Sep 6, 2024  • #5
User Image
Retko
13 discussion posts
Hi, i tried it today. Unfortunately is not working well. I made you a video so you can see how it behaves (my shared onedrive folder: https://1drv.ms/f/s!Au2c29BA5FMKpMcJ0NHuLR2jwteXeA?e=wI8mKe.

As you can see I first clicked in the app window, then pressed my key combination, it didnt do anything . They I pressed in taskbar (it taskbar from display fusion), pressed key combination - and it crashed , reloaded and after some time all windows went down.

Thank you for your efforts ;)
Sep 7, 2024  • #6
Keith Lammers (BFS)'s profile on WallpaperFusion.com
Could you send me a debug log for this?

  • On the DisplayFusion Settings > Troubleshooting tab, change the Logging drop-down to "L1: Log Minimal" and click Apply
  • Reproduce the issue and note the time so we'll know where to check in the log file
  • Click the "Export Info to File" button on the Settings > Troubleshooting tab
  • Reply with the file attached
  • Disable debug logging after sending the log

And also send me a backup of your DisplayFusion Settings? (Settings > Options > Export Settings)

Thanks!
Sep 11, 2024  • #7
User Image
Retko
13 discussion posts
Hi, sorry for late reply. Here are the files requested.
Thank you!!!
• Attachment [protected]: DisplayFusion Backup (2024-10-05 @ 17-47, 10.99.99.107, RETKOPC, SettingsWindow).reg [363,958 bytes]
• Attachment [protected]: DisplayFusionDebugInfo.zip [134,816 bytes]
Oct 5, 2024  • #8
Keith Lammers (BFS)'s profile on WallpaperFusion.com
No worries! Your script doesn't seem to have the extra code I added in post #5 above. Could you try deleting the scripted function, then create a new one using the code from that post?
Oct 10, 2024  • #9
Subscribe to this discussion topic using RSS
Was this helpful?  Login to Vote(-)  Login to Vote(-)