ishmaelcallme Posted March 29, 2007 Share Posted March 29, 2007 I can't seem to start a new topic in the example scripts section, so I thought I would post this here. If you have a laptop that you use both in a docking station with multiple monitors and also standalone, you can strand windows in the other monitors when you undock. This script will move all windows into the primary display without having to unattach the extra monitors in the display properties. Comments welcome. $list = WinList() For $win = 0 To $list[0][0] $state = WinGetState($list[$win][1], '') If (BitAND(2, $state)) Then ;if visable If (BitAND(32, $state)) Then WinSetState($list[$win][1], '', @SW_RESTORE) ;if maximized, then restore If (BitAND(16, $state)) Then WinSetState($list[$win][1], '', @SW_RESTORE) ;if minimized, then restore $pos = WinGetPos($list[$win][1], '') $npos = $pos If $pos[2] > @DesktopWidth Then $npos[2] = @DesktopWidth ;shrink width if needed If $pos[3] > @DesktopHeight Then $npos[3] = @DesktopHeight ;shrink height if needed If $pos[0] + $npos[2] > @DesktopWidth Then $npos[0] = @DesktopWidth - $npos[2];move left if needed If $pos[0] < 0 Then $npos[0] = 0 ;move right if needed If $pos[1] + $npos[3] > @DesktopHeight Then $npos[1] = @DesktopHeight - $npos[3];move up if needed If $pos[1] < 0 Then $npos[1] = 0 ;move down if needed WinMove($list[$win][1], '', $npos[0], $npos[1], $npos[2], $npos[3]) If (BitAND(32, $state)) Then WinSetState($list[$win][1], '', @SW_MAXIMIZE) ;if was maximized, then restore If (BitAND(16, $state)) Then WinSetState($list[$win][1], '', @SW_MINIMIZE) ;if was minimized, then restore EndIf Next Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now