Post Reply

Forums -> UltraMon™ -> Need Help Combining 2 Scripts Together
tkayok   2016-07-31 19:52
Hey i'm very new to all of this scripting stuff and need help combing these two scripts into on one.

Script #1
Const PROFILE = "Default" 'name of the display profile Const ICON_POS_FILE = "C:\Users\brand\Documents\Ultramon Scipts\icons.reg" 'can optionally be set to a .reg file with saved icon positions, otherwise the last saved icon positions will be used. to create the .reg file, export the registry key HKEY_CURRENT_USER\Software\Realtime Soft\UltraMon Components\Saved Positions\Icons Const DELAY = 1 'number of seconds to wait between applying the profile and restoring icon positions Const INSTALL_DIR = "%ProgramFiles%\UltraMon" 'UltraMon installation folder Set sh = CreateObject("WScript.Shell") Set sys = CreateObject("UltraMon.System") 'check if UltraMon 3 or later is installed Set sh = CreateObject("WScript.Shell") umVer = sh.RegRead("HKLM\Software\Realtime Soft\UltraMon\CurrentVersion") 'get the location of the display profile folder dirProfiles = "" If umVer = "" Then 'UltraMon 2 MsgBox "This script requires UltraMon version 3.",, WScript.ScriptName WScript.Quit Else 'UltraMon 3 or later dirProfiles = sh.ExpandEnvironmentStrings("%APPDATA%\Realtime Soft\UltraMon\" & umVer & "\Profiles") End If sh.Run """" & INSTALL_DIR & "\UltraMonShortcuts.exe"" /l """ & dirProfiles & "\" & PROFILE & ".umprofile""",, True If ICON_POS_FILE <> "" Then sh.Run """%WINDIR%\regedit.exe"" /s """ & ICON_POS_FILE & """" WScript.Sleep DELAY * 1000 sys.RestorePositions 2 'POS_ICONS

Script #2
APPS = Array("Razer Comms") 'caption of the windows which should get positioned, can contain a wildcard (*) POS = Array("1921,440,304,580") 'position of each window. a single number means maximized on that monitor, otherwise enter left and top position, optionally followed by width and height Set wnd = CreateObject("UltraMon.Window") For i = 0 To UBound(APPS) If UBound(POS) < i Then MsgBox "Position missing for app " & APPS(i) & ".",, WScript.ScriptName WScript.Quit End If If wnd.Find(APPS(i), "", 1, 0, 0) = True Then posVals = Split(POS(i), ",") numPosVals = UBound(posVals) + 1 If numPosVals < 1 Then MsgBox "Invalid position value for app " & APPS(i) & ".",, WScript.ScriptName WScript.Quit End If If numPosVals = 1 Then wnd.Monitor = CLng(posVals(0)) wnd.ShowState = 3 'maximized Else wnd.Left = CLng(posVals(0)) If numPosVals >= 2 Then wnd.Top = CLng(posVals(1)) If numPosVals >= 3 Then wnd.Width = CLng(posVals(2)) If numPosVals >= 4 Then wnd.Height = CLng(posVals(3)) wnd.ShowState = 2 'normal End If wnd.ApplyChanges 0 End If Next

Thanks You for the Help, sorry for being noob :(
Christian Studer   2016-08-01 14:08
Just copy the code from script 2 and paste it into script 1 at the end (on a new line). This way the display profile will get applied and icon positions will get restored, then the Razer Comms application will get positioned.

If this doesn't work correctly you can send me the combined script to support@realtimesoft.com and I'll take a look at it.

Christian Studer - www.realtimesoft.com
Forums -> UltraMon™ -> Need Help Combining 2 Scripts Together

Post Reply