Processing Ajax...

Title
Close Dialog

Message

Confirm
Close Dialog

Confirm
Close Dialog

Confirm
Close Dialog

Place Calculator on Monitor 3

Description
This script will check whether Calculator is already running, and start it if not. It then moves it to monitor 3 and gives it focus.
Language
C#.net
Minimum Version
Created By
Bruce Wahler
Contributors
-
Date Created
Mar 15, 2016
Date Last Modified
Mar 15, 2016

Scripted Function (Macro) Code

using System;
using System.Drawing;

// The 'windowHandle' parameter will contain the window handle for the:
// - Active window when run by hotkey
public static class DisplayFusionFunction
{
	public static void Run(IntPtr windowHandle)
	{
		// see if Calc is already running
		uint appId = BFS.Application.GetAppIDByFile("*calc.exe");

		// if we couldn't get the Calc window, start it
		if (appId == 0)
			appId = BFS.Application.Start("calc.exe", "");

		// get the window handle
		IntPtr calcWindow = BFS.Application.GetMainWindowByAppID(appId);

		// if the app is minimized, restore it
		if (BFS.Window.IsMinimized(calcWindow))
			BFS.Window.Restore(calcWindow);

		//move the window to Monitor 3 and give it focus
		BFS.Window.MoveToMonitor(3, calcWindow);
		BFS.Window.Focus(calcWindow);
	}
}