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?

Move Window to Position "x" (Triple Monitors Only)

Description
This is a fairly complex but powerful setup, please see the comments and instructions at the top of the script code for details.
Language
C#.net
Minimum Version
Created By
FluffyMule5433355003
Contributors
-
Date Created
Jan 10, 2020
Date Last Modified
Jan 10, 2020

Scripted Function (Macro) Code

using System;
using System.Drawing;

/*
For Triple Monitors Only (Feel free to use/modify however you like tho :)

HOW TO ASSIGN
- Add six copies of this script and name them as per line below.
- As you add each script, change the value of the int variable "WindowsSplitPosition" to the value in the SQUARE [] brackets then Verify Function and Save (OK Button).
- Once you have created all six scripts, select each script, toggle them on and assign the image in the CURVED () brackes:

Script Name | int Value | Image Name
-------------------------------------------------------------------------------------------------------------------------------
"Move Window to Position 1" | [0] | (Windows Aero - Load Desktop Icons Profile #1)
"Move Window to Position 2" | [1] | (Windows Aero - Load Desktop Icons Profile #2)
"Move Window to Position 3" | [2] | (Windows Aero - Load Desktop Icons Profile #3)
"Move Window to Position 4" | [3] | (Windows Aero - Load Desktop Icons Profile #4)
"Move Window to Position 5" | [4] | (Windows Aero - Load Desktop Icons Profile #5)
"Move Window to Position 6" | [5] | (Windows Aero - Load Desktop Icons Profile #6)

HOW TO USE
- Clicking buttons 1, 2 & 3 will move the window to corresponding monitors 1, 2 & 3. *Only buttons 1, 2 & 3 work without ctrl or shift being held.
- SHIFT & Clicking moves the window to one of the below corresponding positions (imagine as 3 monitors split in half, giving you 6 positions from left to right):

Button 1 | Left Monitor | Fill Left Half
Button 2 | Left Monitor | Fill Right Half
Button 3 | Middle Monitor | Fill Left Half
Button 4 | Middle Monitor | Fill Right Half
Button 5 | Right Monitor | Fill Left Half
Button 6 | Right Monitor | Fill Right Half

- CONTROL & Clicking moves the window to one of the below corresponding positions:

Button 1 | Left Monitor | Fill Ten Fourteenths of the Left Side
Button 2 | Left Monitor | Fill Four Fourteenths of the Right Side
Button 3 | Middle Monitor | Fill Left Half
Button 4 | Middle Monitor | Fill Right Half
Button 5 | Right Monitor | Fill Ten Fourteenths of the Left Side
Button 6 | Right Monitor | Fill Four Fourteenths of the Right Side

As you can see, the above values corresponde to the int arrays "WindowSplitShft" and "WindowSplitCtrl" and can be modified to suit. Just make sure you change them so they match in all 6 scripts.

WHY I CREATED THIS SCRIPT
- Firstly I only have 6 buttons for lots of functionality
- Clicking and SHIFT clicking buttons are very useful when ever I want lots of windows on screen and want to quickly arrange each one.
- CONTROL clicking is very useful when I want to use a single window (IE Visual Studio) on the centre monitor and it's child windows (IE Properties, Find, etc) directly left and right of the centre monitor. This allows me a full monitor for my coding window whilst still giving me space for key IDE info left and right. This also allows space for the far left and right positions to be used as needed (IE Windows Explorer, Browser, etc).

Don't know if anyone else will find this useful, but I have been using this for over a year now and found it very helpful so wanted to share.
*/

public static class DisplayFusionFunction
{
	public static void Run(IntPtr windowHandle)
	{
 		if (windowHandle == IntPtr.Zero)
			return;
			
        int WindowSplitPosition = 0;
        int[] WindowSplitShft = new int[] {1, 1, 1, 1, 1, 1};
        int[] WindowSplitCtrl = new int[] {10, 4, 1, 1, 4, 10};
        
        bool IsModifierDown = false;
        int[] WindowSplit = new int[]{};
        int windowX = 0, windowY = 0, windowW = 0, windowH = 0;
        
		Rectangle[] monitors = BFS.Monitor.GetMonitorWorkAreas();
        Rectangle window  = BFS.Window.GetBounds(windowHandle);
        Rectangle monitor = new Rectangle();
        
        if (BFS.Input.IsKeyDown("16"))
        {
            WindowSplit = WindowSplitShft;
            IsModifierDown = true;
        }
        else if (BFS.Input.IsKeyDown("17"))
        {
            WindowSplit = WindowSplitCtrl;
            IsModifierDown = true;
        }
        
        
        if (!IsModifierDown)
        {
            switch (WindowSplitPosition)
            {
                case 0:
                    monitor = monitors[0];
                    windowX = monitor.X;
                    windowW = monitor.Width;
                    break;
                case 1:
                    monitor = monitors[1];
                    windowX = monitor.X;
                    windowW = monitor.Width;
                    break;
                case 2:
                    monitor = monitors[2];
                    windowX = monitor.X;
                    windowW = monitor.Width;
                    break;
            }
        }
        else
        {
            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[1];
                    windowX = monitor.X; 
                    windowW = (monitor.Width / (WindowSplit[2] + WindowSplit[3])) * WindowSplit[2]; 
                    break;
                case 3:
                    monitor = monitors[1];
                    windowX = monitor.X + ((monitor.Width / (WindowSplit[2] + WindowSplit[3])) * WindowSplit[2]); 
                    windowW = (monitor.Width / (WindowSplit[2] + WindowSplit[3])) * WindowSplit[3]; 
                   break;
                case 4:
                    monitor = monitors[2];
                    windowX = monitor.X; 
                    windowW = (monitor.Width / (WindowSplit[4] + WindowSplit[5])) * WindowSplit[4]; 
                    break;
                case 5:
                    monitor = monitors[2];
                    windowX = monitor.X + ((monitor.Width / (WindowSplit[4] + WindowSplit[5])) * WindowSplit[4]); 
                    windowW = (monitor.Width / (WindowSplit[4] + WindowSplit[5])) * WindowSplit[5]; 
                    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);
	}
}