using System;
using System.Drawing;
using System.Collections.Generic;
public static class DisplayFusionFunction
{
public static void Run(IntPtr windowHandle)
{
// Set the monitor you want the windows to move to
uint targetMonitor = 2;
// Set the amount of time (in milliseconds) between loops (lowering this time will increase CPU usage)
uint waitTime = 1000;
// Script setup stuff
var previousList = new List<IntPtr>();
var currentList = new List<IntPtr>();
while (true) // Loop forever (exit the script via its icon in the system tray)
{
// Clear the current list of windows
currentList.Clear();
BFS.General.LogText("MoveNewMitchellShopWindows: Current list cleared: " + currentList.Count.ToString());
// Add the current Outlook or Word window handles to a list
foreach (IntPtr window in BFS.Window.GetVisibleAndMinimizedWindowHandles())
{
if (BFS.Application.GetMainFileByWindow(window).ToLower().Contains("shopstreamxtshell.exe") ||
BFS.Application.GetMainFileByWindow(window).ToLower().Contains("speeddial.exe")
)
{
currentList.Add(window);
BFS.General.LogText("MoveNewMitchellShopWindows: Window added to current list: " + window.ToString() + " " + currentList.Count.ToString());
}
}
// Compare the list from the previous run to the list from the current run
foreach (IntPtr window in currentList)
{
if (!(previousList.Contains(window)))
{
BFS.Window.MoveToMonitorMaximized(targetMonitor, window);
BFS.General.LogText("MoveNewMitchellShopWindows: Window moved to monitor " + targetMonitor.ToString() + ": " + window.ToString());
previousList.Add(window);
BFS.General.LogText("MoveNewMitchellShopWindows: Window added to previous list: " + window.ToString() + " " + previousList.Count.ToString());
}
}
// If the previous list has windows that aren't in the new list, mark them for deletion
var closedWindows = new List<IntPtr>();
foreach (IntPtr window in previousList)
{
if (!(currentList.Contains(window)))
{
closedWindows.Add(window);
BFS.General.LogText("MoveNewMitchellShopWindows: Window marked for deletion: " + window.ToString());
}
}
// Delete the closed windows from the previous list
foreach (IntPtr window in closedWindows)
{
previousList.Remove(window);
BFS.General.LogText("MoveNewMitchellShopWindows: Window deleted: " + window.ToString() + " " + previousList.Count.ToString());
}
// Wait before looping to prevent the CPU from running up
BFS.General.ThreadWait(waitTime);
}
}
}