Const SCRPLAYER_EXE = "C:\Temp\ScrPlayer.exe" 'full path and name of the UltraMon Screen Saver Player executable
Const SCREENSAVER = "%WINDIR%\system32\scrnsave.scr" 'screen saver that should be used
MONS = Array(2, 3) 'list of monitors on which an instance of the screen saver player should get started

Const SCRPLAYER_TITLE = "UltraMon Screen Saver Player"
Const SCRPLAYER_CLASS = "ScrPlayer"
Set wnd = CreateObject("UltraMon.Window")
If wnd.Find(SCRPLAYER_TITLE, SCRPLAYER_CLASS, 3, 0, 0) = True Then
	'already running, close all ScrPlayer instances
	For Each w In wnd.GetAppWindows(False)
		If w.Title = SCRPLAYER_TITLE And w.Class = SCRPLAYER_CLASS Then
			w.Close
		End If
	Next
Else
	'not running yet, start ScrPlayer instances
	Set sys = CreateObject("UltraMon.System")
	Set sh = CreateObject("WScript.Shell")
	numMons = sys.Monitors.Count
	
	For i = 0 To UBound(MONS)
		monId = CLng(MONS(i))
		If monId > 0 And monId <= numMons Then
			Set mon = sys.Monitors(monId - 1)
			If mon.Enabled = True Then
				sh.Run """" & SCRPLAYER_EXE & """ """ & SCREENSAVER & """ " & monId
			End If
		End If
	Next
End If
