using System;
using System.Drawing;
using System.Collections.Generic;
using BinaryFortress.Windows;
public static class DisplayFusionFunction
{
public static void Run(IntPtr windowHandle)
{
// Get all Chrome windows
List<IntPtr> chromeWindows = BFS.Window.GetVisibleWindowHandlesByClassName("Chrome_WidgetWin_1");
// Get the number of monitors
int monitorCount = 3; // Adjust this to BFS.Monitor.GetMonitorCount() if dynamic assignment is preferred
// Check if there are enough monitors
if (BFS.Monitor.GetMonitorCount() < monitorCount)
{
BFS.Dialog.ShowMessageInfo("Not enough monitors. This script requires at least 3 monitors.");
return;
}
// Loop through each Chrome window and move it to a different monitor
for (int i = 0; i < chromeWindows.Count; i++)
{
// Calculate which monitor to move the window to
int targetMonitor = i % monitorCount;BFS.
// Get the bounds of the target monitor
RECT monitorBounds = BFS.Monitor.GetMonitorBoundsByIndex(targetMonitor);
// Move and size the window to fit the monitor
BFS.Window.SetSizeAndLocation(chromeWindows[i], monitorBounds.Left, monitorBounds.Top, monitorBounds.Width, monitorBounds.Height);
}
// Show a message when complete
BFS.Dialog.ShowMessageInfo("All Chrome instances have been moved and resized across " + monitorCount + " monitors.");
}
}using System;
using System.Drawing;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text.RegularExpressions;
// using BinaryFortress.Windows;
public static class DisplayFusionFunction
{
public static void Run(IntPtr windowHandle)
{
// Get all Chrome windows
var processes = (System.Diagnostics.Process.GetProcessesByName("chrome"));
// Get the number of monitors
int monitorCount = 3; // Adjust this to BFS.Monitor.GetMonitorCount() if dynamic assignment is preferred
BFS.General.LogText("monitor count: " + monitorCount);
for(int i = 0; i < processes.Length; i++) {
Process proc = processes[i];
// only run it when the title is Chrome_WidgetWin_1 (regex)
if (Regex.IsMatch(proc.MainWindowTitle, "Chrome_WidgetWin_1")) {
int targetMonitor = i % monitorCount;
BFS.General.LogText("Do more... to screen " + targetMonitor);
BFS.Window.MoveToMonitorMaximized(proc.MainWindowHandle, (uint)targetMonitor);
}
}
// Show a message when complete
BFS.Dialog.ShowMessageInfo("All Chrome instances have been moved and resized across " + monitorCount + " monitors.");
}
}using System;
using System.Drawing;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Text.RegularExpressions;
using System.Windows.Forms;
using System.Text;
public static class DisplayFusionFunction
{
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
static extern int GetWindowText(IntPtr hWnd, StringBuilder lpString, int nMaxCount);
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
static extern bool EnumChildWindows(IntPtr hwndParent, EnumWindowsProc lpEnumFunc, IntPtr lParam);
private delegate bool EnumWindowsProc(IntPtr hWnd, IntPtr lParam);
// Keep track of which monitor to use next
private static int nextMonitorIndex = 1; // Start with 1 if DisplayFusion uses 1-based index
public static void Run(IntPtr windowHandle)
{
// Enumerate all windows
EnumChildWindows(IntPtr.Zero, new EnumWindowsProc(EnumWindowCallback), IntPtr.Zero);
}
private static bool EnumWindowCallback(IntPtr hWnd, IntPtr lParam)
{
StringBuilder windowText = new StringBuilder(256);
if (GetWindowText(hWnd, windowText, 256) > 0)
{
// Specify the window title that you are interested in
if (windowText.ToString().Contains("Suggest A Change"))
{
// Move the window to the next monitor and maximize it
BFS.Window.MoveToMonitorMaximized((uint)nextMonitorIndex, hWnd);
// Update the monitor index, cycling through 1-5
nextMonitorIndex = (nextMonitorIndex % 5) + 1;
}
}
return true; // Continue enumeration
}
}