Processing Ajax...

Close Dialog


Close Dialog

Close Dialog

A recent AVG and Avast antivirus update is preventing DisplayFusion 9.9 from launching on some systems.
If you're running into this issue, please update to the latest DisplayFusion 10.0 Beta.

List Open Window Information

This function lists the window handle, location, and window title for each open window on the system. This code is useful in other functions where you want to find a specific window and do something with it.
Minimum Version
Created By
Date Created
Dec 8, 2014
Date Last Modified
Feb 9, 2015

Scripted Function (Macro) Code

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

// The 'windowHandle' parameter will contain the window handle for the:
// - Active window when run by hotkey
// - Window Location target when run by a Window Location 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)
		// flag to write to file or open Dialog
		bool outputToNotepad = false;

		// get visible window handles
		IntPtr[] handles = BFS.Window.GetVisibleWindowHandles();

		// build debug window text
		string output = "";
		for (int i = 0; i < handles.Length; i++)
			output += string.Format("0x{0}: Location: {1, -37} {2}" + Environment.NewLine, handles[i].ToString("x8"), BFS.Window.GetBounds(handles[i]).ToString(), BFS.Window.GetText(handles[i]));
		if (outputToNotepad)
			// show messagebox with text in Notepad
			string path = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "/OpenWindowInformation.txt";
			System.IO.File.WriteAllText(path, output);
			// show messagebox with text in Dialog Box