-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathAltWindowDrag.ahk
More file actions
73 lines (68 loc) · 2.12 KB
/
AltWindowDrag.ahk
File metadata and controls
73 lines (68 loc) · 2.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
; Needs absolute coordinates (CoordMode "Mouse", "Screen")
AWD_StartAction(resize, button) {
global
MouseGetPos &AWD_MX0, &AWD_MY0, &AWD_Window
AWD_Maximized := WinGetMinMax(AWD_Window)
if (AWD_Maximized = 0)
{
AWD_InResize := resize
AWD_Button := button
; save original dimensions of window
WinGetPos &AWD_X0, &AWD_Y0, &AWD_W0, &AWD_H0, AWD_Window
; TODO: check to make sure we are not moving/resizing the explorer desktop
; or start menu
if (AWD_InResize) {
if (AWD_MX0 >= (AWD_X0+(ceil(AWD_W0/2)))) {
; width grows to the right, x is fixed
AWD_ResizeW := 1
AWD_ResizeX := 0
} else {
; width fixed, x grows to the left
AWD_ResizeW := -1
AWD_ResizeX := 1
}
if (AWD_MY0 >= (AWD_Y0+(ceil(AWD_H0/2)))) {
; height grows down, y is fixed
AWD_ResizeH := 1
AWD_ResizeY := 0
} else {
; height fixed, y grows up
AWD_ResizeH := -1
AWD_ResizeY := 1
}
}
; Run watch subroutine once (as a timer thread)
SetTimer AWD_WatchMouse, -1
}
return
}
; Timer subroutine. Keep checking mouse position at monitor refresh rate (by
; using DwmFlush). First, check to see if we are done. Using a normal timer we
; can't go fast enough to match high refresh rate monitors. cleanup. Otherwise,
; update the window based on mouse location.
AWD_WatchMouse() {
global
SetWinDelay 0
while(1) {
if (!GetKeyState(AWD_Button, "P")) {
return
}
MouseGetPos &AWD_MX, &AWD_MY
local delta_x := (AWD_MX - AWD_MX0)
local delta_y := (AWD_MY - AWD_MY0)
if (AWD_InResize = 1) {
local x := (AWD_ResizeX*delta_x) + AWD_X0
local y := (AWD_ResizeY*delta_y) + AWD_Y0
local w := (AWD_ResizeW*delta_x) + AWD_W0
local h := (AWD_ResizeH*delta_y) + AWD_H0
WinMove x, y, w, h, "ahk_id" AWD_Window
} else {
local x := delta_x + AWD_X0
local y := delta_y + AWD_Y0
WinMove x,y,,,"ahk_id" AWD_Window
}
if (DllCall("dwmapi.dll\DwmFlush")) {
Sleep(0)
}
}
}