## Recommended Posts

My wife and I have a laptop hooked up to the TV via VGA for Hulu and other video watching in the living room. The laptop also serves double duty as a we browsing system for my wife while she is at home with the kids. When the kids are watching TV and Firefox has been left on the TV its unhandy for her to switch the TV back to VGA to pull the window over to the laptop screen so she ends up disabling the secondary monitor (the TV) to empty all the windows onto the primary (laptop screen). So I wrote her a little script to move Firefox to 0,0 and over a board evening at work it turned into this.

The forums really make the language awesome!

```TraySetState(2)

Local \$ahWinList = WinList(), \$iNumberOfWindows = \$ahWinList[0][0]
Local \$iDesktopHypotenuse = Int(Sqrt(((@DesktopWidth * @DesktopWidth) + (@DesktopHeight * @DesktopHeight))))
Local \$iNumberOfVisableWindows

For \$i = 1 To \$ahWinList[0][0]
If \$ahWinList[\$i][0] <> "" And _isVisible(\$ahWinList[\$i][1]) Then \$iNumberOfVisableWindows = \$iNumberOfVisableWindows + 1
Next

Local \$fMoveInc = \$iDesktopHypotenuse / \$iNumberOfVisableWindows
Local \$fPercentOfScreen = \$fMoveInc/\$iDesktopHypotenuse

Local \$iWidthInc = Int(\$fPercentOfScreen * @DesktopWidth)
Local \$iWidthIncCollector = (@DesktopWidth - \$iWidthInc*2)

Local \$iHeightInc = Int(\$fPercentOfScreen * @DesktopHeight)
Local \$iHeightIncCollector = (@DesktopHeight - \$iHeightInc*2)

For \$iCounter = 1 To \$ahWinList[0][0]
If \$ahWinList[\$iCounter][0] <> "" And _isVisible(\$ahWinList[\$iCounter][1]) Then
WinSetState(\$ahWinList[\$iCounter][0], "", @SW_RESTORE)
WinMove(\$ahWinList[\$iCounter][0], "", \$iWidthIncCollector, \$iHeightIncCollector)
\$iWidthIncCollector = \$iWidthIncCollector - \$iWidthInc
\$iHeightIncCollector = \$iHeightIncCollector - \$iHeightInc
EndIf
Next

Func _isVisible(\$hWin)
If BitAND(WinGetState(\$hWin), 2) Then
Return True
Else
Return False
EndIf
EndFunc```

AutoIt changed my life.

##### Share on other sites

Nice, it moved my dock tho

##### Share on other sites

Whats your dock? Some kinda app launch dock?

AutoIt changed my life.

## Create an account

Register a new account

×

• Wiki

• Back

• Git