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 Current Monitor (Selectable List)

Description
This script will show a list of open windows. When you choose the desired window from the list, it will get moved to the current monitor.
Language
C#.net
Minimum Version
Created By
Keith Lammers (BFS)
Contributors
-
Date Created
Aug 6, 2019
Date Last Modified
Aug 6, 2019

Scripted Function (Macro) Code

using System;
using System.Drawing;
using System.Collections.Generic;

public static class DisplayFusionFunction
{
	public static void Run(IntPtr windowHandle)
	{
        var windowTitlesList = new List<string>();

		// Build the list of open window titles
		foreach (IntPtr window in BFS.Window.GetVisibleAndMinimizedWindowHandles())
        {
            string windowTitle = BFS.Window.GetText(window);
            if (!String.IsNullOrEmpty(windowTitle))
            {
                windowTitlesList.Add(windowTitle);
            }
        }
        
        // Convert the list to a string array
        string[] windowTitles = windowTitlesList.ToArray();
        
        // Show the list to choose from
        string selectedWindow = BFS.Dialog.GetUserInputListViewWithFilter("Select the window to move...", windowTitles);

        // Move the window to the current monitor
        BFS.Window.MoveToMonitor(BFS.Monitor.GetMonitorIDByXY(BFS.Input.GetMousePositionX(), BFS.Input.GetMousePositionY()), BFS.Window.GetWindowByTextExact(selectedWindow));
	}
}