Processing Ajax...

Title
Close Dialog

Message

Confirm
Close Dialog

Confirm
Close Dialog

Confirm
Close Dialog

User Image
Bishi
19 discussion posts
Thanks for continued enhancements! Displayfusion is a must have tool!

I use hotkeys to configure my window layouts on the screen but I also find monitor splitting is a great tool. There is a function entry for allowing a window to be maximised but ignore monitor splits, this is very useful but could this be extended to apply to all the other window moving functions for instance 'Size and Move Window to Left Side of Monitor'. I assume this would be possible with a scripted function but I couldn't find anything quite like what I'm after.

Thanks!

EDIT: I've managed to do it as a scripted function (below), I just wonder if there was a neater way. Also ideally I'd like to ignore splits but not ignore any padding those splits might have as I reserve a sliver of my screen left and right for widgets. For now I can just hard-code the padding I guess?

Code

using System;
using System.Drawing;

// 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
{
    public static void Run(IntPtr windowHandle)
    {    
        //check to see if there was an error, if there was, exit function
        if (windowHandle == IntPtr.Zero)
            return;

        //get the position of the window in the monitor, and the current monitor
        Rectangle windowRect = BFS.Window.GetBounds(windowHandle);
        //Rectangle monitorRect = BFS.Monitor.GetMonitorWorkAreaByWindow(windowHandle);
        
        // Get an array of the bounds for all monitors ignoring splits
        Rectangle[] monitorBoundsAll = BFS.Monitor.GetMonitorBoundsNoSplits();
                
        // Get window pos
        Point winPosition = new Point(windowRect.X, windowRect.Y);
        
        foreach (Rectangle monitorRect in monitorBoundsAll)
        {
            if (monitorRect.Contains(winPosition))
            {
                int iFinalWinX = monitorRect.X;
                int iFinalWinY = monitorRect.Y;
                int iFinalWinW = monitorRect.Width / 2;
                int iFinalWinH = monitorRect.Height;

                if(    windowRect.X == iFinalWinX
                    && windowRect.Y == iFinalWinY
                    &&    windowRect.Width == iFinalWinW
                    &&    windowRect.Height == iFinalWinH )
                {
                    return;
                }

                BFS.Window.SetSizeAndLocation(windowHandle, iFinalWinX, iFinalWinY, iFinalWinW, iFinalWinH );
            }
        }        
    }
}
Jun 21, 2021 (modified Jun 21, 2021)  • #1
Owen Muhlethaler (BFS)'s profile on WallpaperFusion.com
Hello,

Unfortunately there isn't a way to separate the splits and padding. You will have to manually adjust for the padding.

Thanks!
Jun 24, 2021  • #2
Subscribe to this discussion topic using RSS
Was this helpful?  Login to Vote(-)  Login to Vote(-)