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?

List Open Window Information

Description
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.
Language
C#.net
Minimum Version
Created By
solaris765
Contributors
-
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);
			BFS.Window.SetSizeAndLocation(BFS.Application.GetMainWindowByAppID(BFS.Application.Start(path,"")),0,0,977,544);
		}
		else
		{
			// show messagebox with text in Dialog Box
			BFS.Dialog.ShowMessageInfoMonospaced(output);
		}
	}
}