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?

Confirm

Are you sure?

Restore Window Positions Using Window Titles (Layout1)

Description
This function will restore the window positions using the values stored in the registry from running "Save 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
Nov 11, 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();

		// If the window title is not empty, try to restore its position from the ones saved to the registry using the "Save Window Positions Using Window Title (Layout1)" script
		foreach (IntPtr window in windowHandles)
		{
			string windowTitle = BFS.Window.GetText(window);
			if (windowTitle != "")
			{
				int windowX;
				int windowY;
				int windowWidth;
				int windowHeight;
				
				int.TryParse(BFS.ScriptSettings.ReadValue(windowTitle + "_X_" + layoutID), out windowX);
				int.TryParse(BFS.ScriptSettings.ReadValue(windowTitle + "_Y_" + layoutID), out windowY);
				int.TryParse(BFS.ScriptSettings.ReadValue(windowTitle + "_Width_" + layoutID), out windowWidth);
				int.TryParse(BFS.ScriptSettings.ReadValue(windowTitle + "_Height_" + layoutID), out windowHeight);
				
				if (windowWidth > 0)
				{
					BFS.Window.SetSizeAndLocation(window, windowX, windowY, windowWidth, windowHeight);
				}
			}
		}
	}
}