Processing Ajax...

Title
Close Dialog

Message

Confirm
Close Dialog

Confirm
Close Dialog

Confirm
Close Dialog

Move to Leftmost or Rightmost Monitor & Split Left or Right

Description
This single script can be used to create:
0. Move to Leftmost Monitor & Split Left
1. Move to Leftmost Monitor & Split Right
2. Move to Rightmost Monitor & Split Left
3. Move to Rightmost Monitor & Split Right
0 - 3 = Window Split Positions (Change "int WindowSplitPosition = 0" to "0", "1", "2" or "3" to select to which position the window moves).
WindowSplit array controls the proportions of the splits (See this line "int[] WindowSplit = new int[] { 3, 1, 1, 3}" which splits windows on left monitor to 3/4, 1/4 and right monitor to 1/4, 3/4)
EG change "{3, 1, 1, 3}" to "{4, 2, 3, 2}" to split left monitor to 4/6, 2/6 and right monitor to 3/5, 2/5.
Language
C#.net
Minimum Version
Created By
FluffyMule54333
Contributors
-
Date Created
Dec 16, 2016
Date Last Modified
Dec 16, 2016

Scripted Function (Macro) Code

using System;
using System.Drawing;

public static class DisplayFusionFunction
{
	public static void Run(IntPtr windowHandle)
	{
 		if (windowHandle == IntPtr.Zero)
			return;
			
        int[] WindowSplit = new int[] { 3, 1, 1, 3 };
        int WindowSplitPosition = 0;
        int windowX = 0, windowY = 0, windowW = 0, windowH = 0;
       
		Rectangle[] monitors = BFS.Monitor.GetMonitorWorkAreas();
        Rectangle window  = BFS.Window.GetBounds(windowHandle);
        Rectangle monitor = new Rectangle();
      
        switch (WindowSplitPosition)
        {
            case 0:
                monitor = monitors[0];
                windowX = monitor.X; 
                windowW = (monitor.Width / (WindowSplit[0] + WindowSplit[1])) * WindowSplit[0]; 
                break;
            case 1:
                monitor = monitors[0];
                windowX = monitor.X + ((monitor.Width / (WindowSplit[0] + WindowSplit[1])) * WindowSplit[0]); 
                windowW = (monitor.Width / (WindowSplit[0] + WindowSplit[1])) * WindowSplit[1]; 
               break;
            case 2:
                monitor = monitors[monitors.Length - 1];
                windowX = monitor.X; 
                windowW = (monitor.Width / (WindowSplit[2] + WindowSplit[3])) * WindowSplit[2]; 
                break;
            case 3:
                monitor = monitors[monitors.Length - 1];
                windowX = monitor.X + ((monitor.Width / (WindowSplit[2] + WindowSplit[3])) * WindowSplit[2]); 
                windowW = (monitor.Width / (WindowSplit[2] + WindowSplit[3])) * WindowSplit[3]; 
                break;
        }
        
        windowY = monitor.Y; 
        windowH = monitor.Height;
        
        if (windowX == window.X && 
            windowY == window.Y && 
            windowW == window.Width && 
            windowH == window.Height)
            return;
            
        BFS.Window.SetSizeAndLocation(windowHandle, windowX, windowY, windowW, windowH);
        BFS.Window.Focus(windowHandle);
	}
}