Const PROFILE_MIRRORING = "Dell + TV" 'name or full path and name of the display profile to be used when mirroring
Const PROFILE_REGULAR = "Default" 'name or full path and name of the display profile to be used when not in mirror mode
Const DIR_ULTRAMON = "%ProgramFiles%\UltraMon" 'UltraMon installation folder
Const DELAY = 3 'number of seconds to wait before applying a profile or launching mirroring

Set sh = CreateObject("WScript.Shell")
umVer = sh.RegRead("HKLM\Software\Realtime Soft\UltraMon\CurrentVersion")
profileDir = sh.ExpandEnvironmentStrings("%APPDATA%\Realtime Soft\UltraMon\" & umVer & "\Profiles\")
mirrExe = DIR_ULTRAMON & "\UMMirrorClient.exe"
shortcutsExe = DIR_ULTRAMON & "\UltraMonShortcuts.exe"

Set wnd = CreateObject("UltraMon.Window")
running = wnd.Find("UltraMonMirrorMsgWnd", "UltraMonMirrorMsgWnd", 3, 0, 0)
profile = ""
If running = True Then
	profile = PROFILE_REGULAR
Else
	profile = PROFILE_MIRRORING
End If
If InStr(profile, "\") = 0 Then profile = profileDir & profile & ".umprofile"

If running = True Then
	sh.Run """" & mirrExe & """ /stop",, True
	WScript.Sleep DELAY * 1000
	sh.Run """" & shortcutsExe & """ /l " & profile
Else
	sh.Run """" & shortcutsExe & """ /l " & profile,, True
	WScript.Sleep DELAY * 1000
	sh.Run """" & mirrExe & """ /start lastmode"
End If
