Processing Ajax...
Save 25% on our desktop apps during our Black Friday/Cyber Monday sale!Save 25% on our desktop apps during our Black Friday/Cyber Monday sale, including DisplayFusion, ClipboardFusion, FileSeek, LogFusion, TrayStatus, and VoiceBot!Save 25% on our desktop apps during our Black Friday/Cyber Monday sale!

Close Dialog


Close Dialog

Close Dialog

Open 3 Sites Maximized on 3 Monitors (Internet Explorer)

This script will open three Internet Explorer windows with the specified URLs, and move them to monitors 1, 2, and 3 respectively.
Minimum Version
Created By
Keith Lammers (BFS)
Date Created
Jul 8, 2015
Date Last Modified
Jul 17, 2015

Scripted Function (Macro) Code

using System;
using System.Drawing;
using System.Runtime.InteropServices;

// 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
	//this is the function that we will use to enumerate through child windows
	[DllImport("user32.dll", PreserveSig = true, SetLastError = false, CharSet = CharSet.Unicode)]
	private static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, IntPtr lpszWindow );
	public static void Run(IntPtr windowHandle)
		string site1 = "";
		string site2 = "";
		string site3 = "";
		//open site1 and move it to monitor 1
		BFS.Application.Start("C:\\Program Files (x86)\\Internet Explorer\\iexplore.exe", site1);
		BFS.Window.MoveToMonitorMaximized(1, GetIE11WindowByURL(site1));
		//open site2 and move it to monitor 2
		BFS.Application.Start("C:\\Program Files (x86)\\Internet Explorer\\iexplore.exe", site2);
		BFS.Window.MoveToMonitorMaximized(2, GetIE11WindowByURL(site2));
		//open site3 and move it to monitor 3
		BFS.Application.Start("C:\\Program Files (x86)\\Internet Explorer\\iexplore.exe", site3);
		BFS.Window.MoveToMonitorMaximized(3, GetIE11WindowByURL(site3));
	//this function will accept a url and try to find an IE11 window with this url open in it
	private static IntPtr GetIE11WindowByURL(string url)
		//enumerate through all windows
		foreach(IntPtr handle in BFS.Window.GetAllWindowHandles())
			//if it isn't a IE window, continue
			if(BFS.Application.GetMainFileByWindow(handle).IndexOf("iexplore.exe", StringComparison.OrdinalIgnoreCase) == -1)
			//if it's not the type of IE window we want, continue
			if(!BFS.Window.GetClass(handle).Equals("IEFrame", StringComparison.Ordinal))
			//we found the IE window, try to find the address bar by searching through the levels. The address bar's class is called "Edit"	
			IntPtr addressBarHandle = FindWindowEx(handle, IntPtr.Zero, "WorkerW", IntPtr.Zero);
			addressBarHandle = FindWindowEx(addressBarHandle, IntPtr.Zero, "ReBarWindow32", IntPtr.Zero);
			addressBarHandle = FindWindowEx(addressBarHandle, IntPtr.Zero, "Address Band Root", IntPtr.Zero);
			addressBarHandle = FindWindowEx(addressBarHandle, IntPtr.Zero, "Edit", IntPtr.Zero);
			//if we couldn't find the address bar, continue
			if(addressBarHandle == IntPtr.Zero)
			//if the addressbar contains the url, return the parent window
			if(BFS.Window.GetText(addressBarHandle).Equals(url, StringComparison.OrdinalIgnoreCase))
				return handle;
		//if we got this far we couldnt find anything. return IntPtr.Zero (null)
		return IntPtr.Zero;