I found this code a while ago, maybe you can use some part of it
http://www.autohotkey.com/board/topic/1 ... ntry119240
Code: Select all
; EasyGlide
; Based on Easy Window Dragging
;
; AutoHotkey Version: 1.0.46+ (uses ?: operator)
; Platform: XP/2k/NT
; Author: Paul Pliska (ManaUser)
; Performance Enhancement: Laszlo
;
; Script Function:
; Make the middle mouse button drag any window, in any internal point.
; Additionally, if you let go while dragging, the window will "glide"
; for short distance, and even bounce off the edges of the screen.
; The distance and "bouncyness" can be adjusted by changing constants.
INERTIA = 1 ;0.97 ; 1 means Glide forever, 0 means not at all.
BOUNCYNESS = 0.95 ;0.03 ; 1 means no speed is lost, 0 means don't bounce.
SENSITIVITY = 0.99 ; Higher is more responsive, lower smooths out glitchs more.
; Must be greater than 0 and no higher than 1.
#notrayicon
#SingleInstance Force
#NoEnv
SetBatchLines -1 ; Run faster
SetWinDelay -1 ; Makes the window moves faster/smoother.
CoordMode Mouse, Screen ; Switch to screen/absolute coordinates.
SpeedA := 1 - SENSITIVITY
SetTimer WorkAreaCheck, 10000 ;Just in case they move the task bar.
GoSub WorkAreaCheck ;or change resolution.
~*Escape::
ExitApp
~*LButton:: ; Clicking a mouse button stops glide.
~*RButton::
SetTimer Glide, Off
Return
MButton::
SetTimer Glide, Off
MouseGetPos LastMouseX, LastMouseY, MouseWin
WinGet WinState, MinMax, ahk_id %MouseWin%
IfNotEqual WinState, 0 ; If the window is maximized, just to normal Middle Click
{
Click Middle
Return
}
WinGetPos WinX, WinY, WinWidth, WinHeight, ahk_id %MouseWin%
SetTimer WatchMouse, 10 ; Track the mouse as the user drags it
Return
WatchMouse:
If !GetKeyState("MButton","P") {
SetTimer WatchMouse, Off ; MButton has been released, so drag is complete.
SetTimer Glide, 10 ; Start gliding
Return
}
; Drag: Button is still pressed
MouseGetPos MouseX, MouseY
WinX += MouseX - LastMouseX
WinY += MouseY - LastMouseY
;Enforce Boundries
WinX := WinX < WorkAreaLeft ? WorkAreaLeft : WinX+WinWidth > WorkAreaRight ? WorkAreaRight-WinWidth : WinX
WinY := WinY < WorkAreaTop ? WorkAreaTop : WinY+WinHeight > WorkAreaBottom ? WorkAreaBottom-WinHeight : WinY
WinMove ahk_id %MouseWin%,, WinX, WinY
SpeedX := SpeedX*SpeedA + (MouseX-LastMouseX)*SENSITIVITY
SpeedY := SpeedY*SpeedA + (MouseY-LastMouseY)*SENSITIVITY
LastMouseX := MouseX, LastMouseY := MouseY
Return
Glide:
SpeedX *= INERTIA
SpeedY *= INERTIA
If (Abs(SpeedX) < 0.2 AND Abs(SpeedY) < 0.2) {
SetTimer Glide, Off ; It's barely moving, bring it to a complete stop
Return
}
WinX += SpeedX, WinY += SpeedY
If (WinX < WorkAreaLeft OR WinX + WinWidth > WorkAreaRight)
SpeedX *= -BOUNCYNESS
If (WinY < WorkAreaTop OR WinY + WinHeight > WorkAreaBottom)
SpeedY *= -BOUNCYNESS
WinX := WinX < WorkAreaLeft ? WorkAreaLeft : WinX+WinWidth > WorkAreaRight ? WorkAreaRight-WinWidth : WinX
WinY := WinY < WorkAreaTop ? WorkAreaTop : WinY+WinHeight > WorkAreaBottom ? WorkAreaBottom-WinHeight : WinY
WinMove ahk_id %MouseWin%,, WinX, WinY
Return
WorkAreaCheck:
SysGet WorkArea, MonitorWorkArea
Return