#include <GuiConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <WinAPI.au3> #include <Misc.au3> ; Global $hUser32_Dll = DllOpen("User32.dll") $GUI = GUICreate("_MoveWindowByMousePointer_Proc Demo!", 300, 200) GUICtrlCreateLabel("Click on any window to Auto-Drag it by mose move" & @CRLF & "(click again to release it)", _ 10, 80, 280, 50, $SS_CENTER) GUICtrlSetFont(-1, 8.5, 800) GUISetState(@SW_SHOW, $GUI) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE DllClose($hUser32_Dll) Exit EndSwitch If _IsPressed(1, $hUser32_Dll) Then _MoveWindowByMousePointer_Proc() WEnd Func _MoveWindowByMousePointer_Proc() Local $aMPos, $st_Point, $hCurrentWnd, $aWin_Pos $aMPos = MouseGetPos() $st_Point = DllStructCreate($tagPOINT) DllStructSetData($st_Point, "X", $aMPos[0]) DllStructSetData($st_Point, "Y", $aMPos[1]) $hCurrentWnd = _WinAPI_GetAncestor(_WinAPI_WindowFromPoint($st_Point), $GA_ROOT) $aWin_Pos = WinGetPos($hCurrentWnd) $iMLeft_Rel = $aMPos[0]-$aWin_Pos[0] $iMTop_Rel = $aMPos[1]-$aWin_Pos[1] Sleep(200) While 1 $aMPos = MouseGetPos() WinMove($hCurrentWnd, "", $aMPos[0]-$iMLeft_Rel, $aMPos[1]-$iMTop_Rel) Sleep(10) If _IsPressed(1, $hUser32_Dll) Then ExitLoop WEnd Sleep(200) EndFunc |