Post Reply

Forums -> UltraMon™ -> Window loosing focus on monitor(s) enable/disable
Steve   2015-11-04 19:28
Whenever I enable/disable monitors, the window that currently has focus looses focus, and the focus changes to a window that is minimised on the taskbar.

This has been happening for a while, and I have put up with it, but realised that it was unlikely to be intended behaviour.

Am I correct?

W764 3.3.0
Christian Studer   2015-11-05 13:43
How do you disable/enable the monitor? I tested via UltraMon menu > Display Settings, but noticed no change in focus, the Display Settings dialog still had the focus after the display configuration change.

Christian Studer - www.realtimesoft.com
Steve   2015-11-05 19:43
By using hotkeys with the DisableEnableMonitor script. One with monitors 2&3 defined, and one with monitors 2,3&4 defined.
Christian Studer   2015-11-06 13:36
I've been able to reproduce the issue when re-enabling a monitor, happens because the script restores window positions.

To prevent this, change line 3 of the script to the following:

Const POS_ALL = &H3

This way only icon and desktop item positions will get restored.

I'll look into this for the next release.

Christian Studer - www.realtimesoft.com
Steve   2015-11-07 21:35
This looks like it is going to be a bit more complex that I first thought.

Having looked at your suggestion, and then the script I am using, there are significant discrepancies. It is closer to the DisableEnableMonitorX script, but still isn't the same.

I have been using this script for a LONG time so can't remember its genesis. The For Each at the end is not something I would have added.

The script is:
DisableEnableMonitor23.vbs --------------------
'Copyright 2002 by Realtime Soft

Const POS_WINDOWS = &H1
Const POS_ICONS = &H2
Const POS_DESKTOPITEMS = &H4
Const POS_ALL = &H7

Set sys = CreateObject("UltraMon.System")
Set wnd = CreateObject("UltraMon.Window")
Set mon2 = sys.Monitors("2")
Set mon3 = sys.Monitors("3")
Set mon4 = sys.Monitors("4")
deskLeft = sys.DesktopLeft
deskTop = sys.DesktopTop
deskRight = deskLeft + sys.DesktopWidth
deskBottom = deskTop + sys.DesktopHeight
primaryMonId = sys.Monitors("Primary").ID

If mon2.Enabled = True Then
mon2.Enabled = False
mon3.Enabled = False
mon4.Enabled = False
sys.ApplyMonitorChanges
Else
mon2.Enabled = True
mon3.Enabled = True
sys.ApplyMonitorChanges
End If

For Each w In wnd.GetAppWindows(True) 'move all orphan windows to primary monitor
If (w.Left + w.Width) <= deskLeft Or w.Left >= deskRight Or (w.Top + w.Height) <= deskTop Or w.Top >=

deskBottom Then
w.Monitor = primaryMonId
w.ApplyChanges 3 'resize to fit and clip to workspace
End If
Next
--------------------------------------
Christian Studer   2015-11-08 14:46
For your specific script there's an easy fix, just ignore minimized windows in the loop at the end which moves offscreen windows to the primary monitor:

For Each w In wnd.GetAppWindows(True) 'move all orphan windows to primary monitor If w.ShowState <> 1 Then 'SHOWSTATE_MINIMIZED If (w.Left + w.Width) <= deskLeft Or w.Left >= deskRight Or (w.Top + w.Height) <= deskTop Or w.Top >= deskBottom Then w.Monitor = primaryMonId w.ApplyChanges 3 'resize to fit and clip to workspace End If End If Next

Christian Studer - www.realtimesoft.com
Steve   2015-11-08 15:57
That has solved it, but not sure why.
Was it trying to move minimised windows?
Christian Studer   2015-11-09 13:36
Yes, the coordinates for minimized windows are offscreen.

Christian Studer - www.realtimesoft.com
Forums -> UltraMon™ -> Window loosing focus on monitor(s) enable/disable

Post Reply