Binary Fortress
Binary Fortress Software
CheckCentral
ClipboardFusion
CloudShow
CloudShow Manager
DisplayFusion
FileSeek
HashTools
LogFusion
Notepad Replacer
Online Base64 Decoder
Online Base64 Encoder
Online JSON Formatter
ShellSend
TrayStatus
VoiceBot
WallpaperFusion
Window Inspector
More Apps...
DisplayFusion
CheckCentral
CloudShow
ClipboardFusion
FileSeek
TrayStatus
VoiceBot
WallpaperFusion
Display
Fusion
by Binary Fortress Software
Download
Download
Change Log
Download Beta
Beta Change Log
License (EULA)
Features
Free vs Pro
More
Screenshots
Scripted Functions (Macros)
Languages
Help
Help Guide
FAQ
Discussions
Contact Us
Find My License
Mailing Address
Advanced Settings
Purchase
Login / Register
WARNING: You currently have Javascript disabled!
This website will not function correctly without Javascript enabled.
Title
Message
OK
Confirm
Yes
No
List Open Windows and Select to Focus
Return to DisplayFusion Scripted Functions (Macros)
Description
This script will show a dialog with all of the open windows with their monitor ID appended. Selecting one will move it to the mouse cursor monitor and give it focus.
Language
C#.net
Minimum Version
9.9+
Created By
Keith Lammers (BFS)
Contributors
-
Date Created
Feb 23, 2022
Date Last Modified
Feb 23, 2022
Scripted Function (Macro) Code
Copy
Select All
using System; using System.Drawing; using System.Text.RegularExpressions; public static class DisplayFusionFunction { public static void Run(IntPtr windowHandle) { // Get the monitor ID of the monitor that the mouse is currently on uint currentMonitorID = BFS.Monitor.GetMonitorIDByXY(BFS.Input.GetMousePositionX(), BFS.Input.GetMousePositionY()); // Get the visible and minimized windows IntPtr[] windowHandles = BFS.Window.GetVisibleAndMinimizedWindowHandles(); // Loop through the window handles to get their window titles string[] windowTitles = new string[windowHandles.Length]; for (int i = 0; i < windowHandles.Length; i++) { windowTitles[i] = BFS.Window.GetText(windowHandles[i]); } // Remove the empty window titles and add the monitor ID for each one string[] windowTitlesNonEmpty = new string[windowTitles.Length]; for (int i = 0; i < windowHandles.Length; i++) { if (windowTitles[i].Length > 0) { windowTitlesNonEmpty[i] = windowTitles[i] + " :" + BFS.Monitor.GetMonitorIDByWindow(windowHandles[i]).ToString(); } } // Prompt the user to select one string selectedWindowTitle = BFS.Dialog.GetUserInputListViewWithFilter("Select the window to focus...", windowTitlesNonEmpty); // Strip the monitor ID from the selected window title selectedWindowTitle = Regex.Replace(selectedWindowTitle, @"\s:\d+$", string.Empty); // Move the window to the current monitor and give it focus int selectedWindowIndex = Array.IndexOf(windowTitles, selectedWindowTitle); if (selectedWindowIndex >= 0) { BFS.Window.MoveToMonitor(currentMonitorID, windowHandles[selectedWindowIndex]); BFS.Window.Focus(windowHandles[selectedWindowIndex]); } else { BFS.Dialog.ShowMessageError("Something went wrong, can't find the selected window's index."); } } }