Const EXE = "%ProgramFiles(x86)%\Mozilla Firefox\firefox.exe" 'application to launch, in this case Firefox
SITES = Array("http://www.realtimesoft.com", "http://www.microsoft.com") 'sites which should get opened
WND_CAPTIONS = Array("Realtime Soft - Mozilla Firefox", "Microsoft *- Mozilla Firefox") 'window caption of each site
MONITORS = Array(2, 3) 'number of the monitor each site should be put on
FULLSCREEN = True 'True if fullscreen mode should be used, False otherwise
TERMINATE_EXISTING_INSTANCES = True 'True if existing instances of the application should get closed at startup, False otherwise
DELAY_APPSTART = 5 'number of seconds to wait for the application to start
DELAY_SWITCH_TO_WINDOWED = 1 'number of seconds to wait between switching application to windowed mode and moving the window

Set sh = CreateObject("WScript.Shell")
Set wnd = CreateObject("UltraMon.Window")

If TERMINATE_EXISTING_INSTANCES = True Then
	exeExp = sh.ExpandEnvironmentStrings(EXE)
	wndFound = False
	For Each w In wnd.GetAppWindows(False)
		If StrComp(w.ProcessExe, exeExp, 1) = 0 Then
			w.Close
			wndFound = True
		End If
	Next
	
	If wndFound = True Then WScript.Sleep DELAY_APPSTART * 1000
End If

wndChangeFlags = 1 + 2 'WNDCHANGE_RESIZE_TO_FIT + WNDCHANGE_CLIP_TO_WORKSPACE
If FULLSCREEN = True Then wndChangeFlags = 0

For i = 0 To UBound(SITES)
	sh.Run """" & EXE & """ -new-window " & SITES(i)
	If wnd.Find(WND_CAPTIONS(i), "", 1, 0, DELAY_APPSTART * 1000) = True Then
		caption = (wnd.Style And &H00C00000) <> 0 'WS_CAPTION = &H00C00000

		If FULLSCREEN = False And caption = False Then
			'window is in fullscreen mode, switch to windowed mode
			wnd.Activate
			sh.SendKeys "{F11}"
			WScript.Sleep DELAY_SWITCH_TO_WINDOWED * 1000
		End If

		wnd.Monitor = MONITORS(i)
		wnd.ApplyChanges wndChangeFlags
		
		If FULLSCREEN = True And caption = True Then
			'window is in windowed mode, switch to fullscreen mode
			wnd.Activate
			sh.SendKeys "{F11}"
		End If
	End If
Next
