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 the X, Y, Width, Height of the two positions here
Rectangle positionA = new Rectangle(0, 0, 960, 1040);
Rectangle positionB = new Rectangle(960, 0, 960, 1040);
// Set the process name of the application here
String processName = "notepad.exe";
// Check if there are any open windows at either position
bool positionAOccupied = false;
bool positionBOccupied = false;
foreach (IntPtr window in BFS.Window.GetVisibleWindowHandles())
{
if (BFS.Application.GetMainFileByWindow(window).Contains(processName.ToLower()))
{
Rectangle bounds = BFS.Window.GetBounds(window);
if (bounds == positionA)
{
positionAOccupied = true;
}
else if (bounds == positionB)
{
positionBOccupied = true;
}
}
}
// Place the new window depending on where the open ones are
if (positionAOccupied && !positionBOccupied)
{
BFS.Window.SetSizeAndLocation(windowHandle, positionB.X, positionB.Y, positionB.Width, positionB.Height);
}
else
{
BFS.Window.SetSizeAndLocation(windowHandle, positionA.X, positionA.Y, positionA.Width, positionA.Height);
}
}
}