Processing Ajax...

Title
Close Dialog

Message

Confirm
Close Dialog

Confirm
Close Dialog

Confirm
Close Dialog

Restart Firefox in Full Screen and Spanned

Description
This script will kill Firefox, start it back up, then full screen and span it.
Language
C#.net
Minimum Version
Created By
Thomas Malloch (BFS)
Contributors
-
Date Created
Dec 19, 2014
Date Last Modified
Dec 19, 2014

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
//   - 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)
	{
		//get the firefox appid
		uint firefox = BFS.Application.GetAppIDByFile("*firefox.exe");
		
		//if firefox is running, kill it
		if(firefox != 0)
		{	
			BFS.Application.Kill(firefox);
			BFS.Application.WaitForExitByAppID(firefox, 5000);
		}
		
		//start a new instance of firefox
		firefox = BFS.Application.Start("C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe", "");
		
		//wait up to 5s for firefox to start (50 * 100ms)
		for(int i = 0; (i < 50) && (!BFS.Application.IsAppRunningByAppID(firefox)); i++)
			BFS.General.Sleep(100);
			
		//focus firefox
		BFS.Window.Focus(BFS.Application.GetMainWindowByAppID(firefox));
		BFS.General.Sleep(1000);
		
		//make firefox full screen
		BFS.Input.SendKeys("{F11}");
		BFS.General.Sleep(3000);
				
		//span firefox across all monitors
		BFS.DisplayFusion.RunFunction("Span Window Across All Monitors");
		
		
	}
}