W2lkm2n Posted January 19, 2013 Share Posted January 19, 2013 This will "float" windows defined in $WINDOWS array to the left edge of the screen like this: If you hover the mouse over the desired window's edge, it will float in, and you can use it. If you move the mouse out of the window area, it will float back. If you exit the script, the windows will restore their original positions. If the sum of the window heights would exceed the Desktop height, nothing will happen to the windows which wouldn't fit. You can resize, close and open windows, they will jump to the desired position, but you have to move the mose there in that case. expandcollapse popup#include <Constants.au3> #include <WinAPI.au3> #include <Misc.au3> _Singleton(@ScriptName) ; window titles here Const $WINDOWS[3] = ['[CLASS:CalcFrame]', '[CLASS:HH Parent]', '[CLASS:Notepad]'] Const $MARGIN = 20 OnAutoItExitRegister("RestoreWindows") Global $iWinCount, $aOriginalPositions[1] For $iWinCount = 0 To UBound($WINDOWS) - 1 ReDim $aOriginalPositions[$iWinCount + 1] $aOriginalPositions[$iWinCount] = WinGetPos($WINDOWS[$iWinCount]) Next While 1 For $sWindow In $WINDOWS MoveWindow($sWindow) Next Sleep(50) WEnd Func MoveWindow($sWinTitle) Local $iY = CalculateYPos($sWinTitle) If $iY > @DesktopHeight Then Return Local $hWnd = WinGetHandle($sWinTitle) If @error Then Return Local $aWinPos = WinGetPos($hWnd) If $aWinPos = 0 Then Return Local $aMousePos = MouseGetPos() If $aMousePos[0] <= $MARGIN And _ ($aMousePos[1] >= $iY And $aMousePos[1] <= ($iY + $aWinPos[3])) And _ $aWinPos[0] < 0 Then _WinAPI_SetWindowPos($hWnd, $HWND_TOP, 0, 0, 0, 0, BitOR($SWP_NOMOVE, $SWP_NOSIZE)) WinMove($hWnd, '', 0, $iY, $aWinPos[2], $aWinPos[3], 2) ElseIf ($aWinPos[0] >= 0) And ($aMousePos[0] > $aWinPos[2] + $MARGIN Or _ ($aMousePos[1] < $iY - $MARGIN Or $aMousePos[1] > ($iY + $aWinPos[3] + $MARGIN))) Then WinMove($hWnd, '', -$aWinPos[2] + 10, $iY, $aWinPos[2], $aWinPos[3], 2) EndIf EndFunc ;==>MoveWindow Func CalculateYPos($sWinTitle) Local $iY = 0, $aPos For $sWindow In $WINDOWS If $sWindow = $sWinTitle Then ExitLoop $aPos = WinGetPos($sWindow) If Not @error Then $iY = $iY + $aPos[3] Next Return $iY EndFunc ;==>CalculateYPos Func RestoreWindows() Local $i, $aPos For $i = 0 To UBound($WINDOWS) - 1 $aPos = $aOriginalPositions[$i] If WinExists($WINDOWS[$i]) Then WinMove($WINDOWS[$i], '', $aPos[0], $aPos[1]) Next EndFunc ;==>RestoreWindows Any advice appreciated! mesale0077 1 Link to comment Share on other sites More sharing options...
spudw2k Posted January 21, 2013 Share Posted January 21, 2013 Neat stuff. Feels a slightly choppy, but overall has a nice aesthetic to it. Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX Builder Misc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retrieve SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose Array Projects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalc Cool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
Mat Posted January 22, 2013 Share Posted January 22, 2013 It would cool if this could be activated by dragging a window to an edge, and then de-activated by moving it away. Probably a little tricky to do that nicely for other windows though. Would have to have some way of preventing aero snap as well. Doesn't deal with multiple monitors either. I'd also have some kind of focus setting, where a window isn't rolled back to hidden while it has focus. I tend to move the mouse away when I'm typing, which makes this not so useful for notepad. Turn this into a full program and it would be very cool though. And very useful AutoIt Project Listing 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