Processing Ajax...

Title
Close Dialog

Message

Confirm
Close Dialog

Confirm
Close Dialog

Save Window Positions Using Window Titles (Layout1)

Description
This function will get the bounds for all open windows, and save their locations to the registry. You can then restore them using the "Restore Window Positions Using Window Titles (Layout1)" script.
Language
C#.net
Minimum Version
Created By
Keith Lammers (BFS)
Contributors
-
Date Created
Sep 25, 2015
Date Last Modified
Sep 25, 2015

Scripted Function (Macro) Code

using System;
using System.Drawing;

public static class DisplayFusionFunction
{
	public static void Run(IntPtr windowHandle)
	{
		// You can duplicate this script, then change layoutID to something different to save another layout
		string layoutID = "Layout1";
		IntPtr[] windowHandles = BFS.Window.GetVisibleWindowHandles();
		foreach (IntPtr window in windowHandles)
		{
			// Get the window title and bounds
			string windowTitle = BFS.Window.GetText(window);
			Rectangle windowBounds = BFS.Window.GetBounds(window);
			
			// If the window title isn't blank, write the window's x, y, width, and height values to the registry
			if (windowTitle != "")
			{
				BFS.ScriptSettings.WriteValue(windowTitle + "_X_" + layoutID, windowBounds.X.ToString());
				BFS.ScriptSettings.WriteValue(windowTitle + "_Y_" + layoutID, windowBounds.Y.ToString());
				BFS.ScriptSettings.WriteValue(windowTitle + "_width_" + layoutID, windowBounds.Width.ToString());
				BFS.ScriptSettings.WriteValue(windowTitle + "_height_" + layoutID, windowBounds.Height.ToString());
			}
		}
	}
}