Post Reply

Forums -> UltraMon™ -> UltraMon.Window & UltraMon.System objects not reliable?
todd   2010-09-07 02:41
Hello,

I have 4 monitors in a 2 x 2 grid configuration. I modified one of the sample scripts to give ma a hot-key that will "maximize" the current window to occupy two full monitors (vertically). The script is supposed to determine which monitor the window is in, and then "maximize" to that side of the 4x4 grid.

However, the Ultramon.Window.Monitor property seems to be unreliable. It generally returns 0 (no matter which monitor the active window is in) but sometimes returns other numbers.

The result is that when I use my hot-key, I never know which 2 monitors (left or right) my window will be maximized to.

Here is the script:

Const RESTORED_WIDTH = 1280
Const RESTORED_HEIGHT = 1024

Const SHOWSTATE_NORMAL = 2
Const SHOWSTATE_MAXIMIZED = 3
Const SHOWSTATE_MAXIMIZED_DESKTOP = 4
Set wnd = CreateObject("UltraMon.Window")
If wnd.GetForegroundWindow() = True Then
Set sys = CreateObject("UltraMon.System")
' Assumed monitor positions:
' 3 4
' 1 2
dim monTop, monBottom
Wscript.echo wnd.Monitor

if wnd.Monitor = 1 or wnd.Monitor = 3 then
set monTop = sys.Monitors(2)
set monBottom = sys.Monitors(0)
else
set monTop = sys.Monitors(3)
set monBottom = sys.Monitors(1)
end if


'calculate position/size for a window stretched across top and bottom monitors
posLeft = monTop.WorkLeft
posTop = monTop.WorkTop
posRight = monTop.WorkLeft + monTop.WorkWidth
posBottom = monBottom.WorkTop + monBottom.WorkHeight
szWidth = posRight - posLeft
szHeight = posBottom - posTop

'check if the window is maximized across the two monitors, or if it isn't
If (wnd.ShowState = SHOWSTATE_NORMAL Or wnd.ShowState = SHOWSTATE_MAXIMIZED_DESKTOP) _
And wnd.Left = posLeft And wnd.Top = posTop And wnd.Width = szWidth And wnd.Height = szHeight Then
'restore window to top monitor
'wnd.Monitor = LEFT_MONITOR_ID
wnd.Width = RESTORED_WIDTH
wnd.Height = RESTORED_HEIGHT
wnd.CenteredWorkspace = True
Else
'maximize window across two monitors
wnd.ShowState = SHOWSTATE_NORMAL
wnd.Left = posLeft
wnd.Top = posTop
wnd.Width = szWidth
wnd.Height = szHeight
End If

wnd.ApplyChanges 0
End If

Thanks
Christian Studer   2010-09-07 09:16
Does this happen with all applications, and also immediately after a system restart?

I tested on Windows 7 with UltraMon 3.0.10 and various applications, but so far noticed no problems. Here's the script I used for testing:Set wnd = CreateObject("UltraMon.Window") msg = "" If wnd.GetForegroundWindow() = True Then msg = "Foreground window is on monitor " & wnd.Monitor & "." Else msg = "No foreground window." End If MsgBox msg,, WScript.ScriptName

Christian Studer - www.realtimesoft.com
todd   2010-09-07 10:42
I created another hotkey to run the script that you provided, and no matter which monitor the active window is on, the popup always comes on Monitor 0.

Thanks
Christian Studer   2010-09-08 09:50
Are you on 64-bit Windows? I just looked into a similar issue with a customer, might be the same problem.

Christian Studer - www.realtimesoft.com
J Dub   2010-09-12 06:00
Can anyone tell me how to stop the annoying ultramon pop-up that asks me if i want to purchase it from popping up every time i log in now that my free trial period has expired?
Christian Studer   2010-09-12 10:15
If you don't want to purchase UltraMon, go to Control Panel > Programs and Features (Add or Remove Programs on Windows XP) to uninstall the software.

Christian Studer - www.realtimesoft.com
Forums -> UltraMon™ -> UltraMon.Window & UltraMon.System objects not reliable?

Post Reply