This example is show, that window can be "attached" (like magnetic) to edges of the screen (or other app)...
But there is one(?) problem - when you drag the window, the script is paused, so you will see the results (of "attaching" process) only after release the mouse (ending of draging).
If this will be fixed(?), then not only this function will be much usefull, and more others (in fact, all our scripts will be much productive and practical
here we go...
$AttachRange = 70 $AttachSpeed = 100 $HwndGui = GUICreate("Attach Window GUI to screen edges") GUICtrlCreateLabel("Drag me to the edges of your screen ;-) ", 50, 50, 350) GUICtrlSetFont(-1, 14) GUISetState() While 1 $Msg = GUIGetMsg() If $Msg = -3 Then Exit _WinAttach($HwndGui, $AttachRange, $AttachSpeed) WEnd Func _WinAttach($hWnd, $AttachRange=20, $AttachSpeed=3) Local $OldOpt = Opt("WinTitleMatchMode", 4) Local $WinPosArr = WinGetPos($hWnd) Local $WidthHeightArr = WinGetClientSize($hWnd) If IsArray($WinPosArr) And IsArray($WidthHeightArr) Then Local $xPos = $WinPosArr[0] Local $yPos = $WinPosArr[1] Local $Width = $WidthHeightArr[0] Local $Height = $WinPosArr[3] Local $TrayPosHeight = WinGetPos("classname=Shell_TrayWnd") If IsArray($TrayPosHeight) Then $TrayPosHeight = $TrayPosHeight[3] If $xPos >= (@DesktopWidth-($Width+$AttachRange)) And ($xPos+$Width-15) < (@DesktopWidth-22) Then Local $xDestPos = @DesktopWidth-$Width While $xPos < $xDestPos Sleep(100/$AttachSpeed) WinMove($hWnd, "", $xPos, $yPos) $xPos += 5 WEnd EndIf If $xPos <= $AttachRange And $xPos > 8 Then Local $xDestPos = -2 While $xPos > $xDestPos Sleep(100/$AttachSpeed) WinMove($hWnd, "", $xPos, $yPos) $xPos -= 5 WEnd EndIf If $yPos >= (@DesktopHeight-($TrayPosHeight+$Height+$AttachRange)) And _ ($TrayPosHeight+$yPos+$Height-15) < (@DesktopHeight-22) Then Local $yDestPos = @DesktopHeight-$Height-$TrayPosHeight+4 While $yPos < $yDestPos Sleep(100/$AttachSpeed) WinMove($hWnd, "", $xPos, $yPos) $yPos += 5 WEnd EndIf If $yPos <= $AttachRange And $yPos > 8 Then Local $yDestPos = -2 While $yPos > $yDestPos Sleep(100/$AttachSpeed) WinMove($hWnd, "", $xPos, $yPos) $yPos -= 5 WEnd EndIf EndIf Opt("WinTitleMatchMode", $OldOpt) EndFunc
Edited by MsCreatoR, 21 October 2007 - 10:16 PM.









