0
我有一個多屏幕計算機系統。有一段時間,由於我不明白的原因,對話框顯示在錯誤的顯示器上。例如,我將在監視器A中運行一個程序,並在顯示器D中打開一個OK框。這非常令人沮喪。執行VBS腳本後關閉控制檯
我發現了一個VBS腳本稱爲「PositionDialogs.vbs」這裏找到:https://www.realtimesoft.com/ultramon/scripts/
Const SNAP_TO_MONITOR = False 'set this to True to ensure dialogs aren't placed between two monitors
Const INTERVAL = 2 'number of seconds the script waits before enumerating open windows again
Set sys = CreateObject("UltraMon.System")
Set wnd = CreateObject("UltraMon.Window")
Set wndParent = CreateObject("UltraMon.Window")
'create the two maps used to store positioned windows
Set arrAdd = CreateObject("Scripting.Dictionary")
Set arrLookup = CreateObject("Scripting.Dictionary")
Do While True
'enumerate all application windows
For Each w In wnd.GetAppWindows(True)
If w.HWndParent <> 0 Then
wndParent.HWnd = w.HWndParent
move = True
If arrLookup.Exists(w.HWnd) = True Then move = False
arrAdd.Add w.HWnd, 0
If move = True Then
If SNAP_TO_MONITOR = False Then
If w.Monitor <> wndParent.Monitor Then
w.Monitor = wndParent.Monitor
w.ApplyChanges 1 + 2 'WNDCHANGE_RESIZE_TO_FIT + WNDCHANGE_CLIP_TO_WORKSPACE
End If
Else
Set parentMon = sys.Monitors(wndParent.Monitor - 1)
parentLeft = parentMon.WorkLeft
parentTop = parentMon.WorkTop
parentRight = parentLeft + parentMon.WorkWidth
parentBottom = parentTop + parentMon.WorkHeight
dlgLeft = w.Left
dlgTop = w.Top
dlgRight = dlgLeft + w.Width
dlgBottom = dlgTop + w.Height
If dlgLeft < parentLeft Then
w.Left = parentLeft
ElseIf dlgRight > parentRight Then
w.Left = parentRight - w.Width
End If
If dlgTop < parentTop Then
w.Top = parentTop
ElseIf dlgBottom > parentBottom Then
w.Top = parentBottom - w.Height
End If
w.ApplyChanges 0
End If
End If
End If
Next
'swap maps, then clear arrAdd. this way we don't have entries for windows which no longer exist
Set temp = arrLookup
Set arrLookup = arrAdd
Set arrAdd = temp
Set temp = Nothing
arrAdd.RemoveAll
WScript.Sleep INTERVAL * 1000
Loop
,將移動對話框到任何顯示器的說法。 我使用批處理文件在Windows啓動時運行它,並將其作爲進程運行。我的問題是,顯示的控制檯窗口不會消失,除非我單擊X關閉它。
浴文件看起來是這樣的:
wscript PositionDialogs.vbs
exit
我以爲有什麼我可以添加到腳本,使其自身加載到內存中結束後?如果是這樣,什麼?
嘗試使用'cscript'而不是'wscript' .. 。 – aschipfl
它連續運行。 – 2016-04-25 22:52:15
並在開始 - 運行對話框(Winkey + R)中輸入它 – 2016-04-26 00:36:44