-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathexample.ahk
62 lines (53 loc) · 1.69 KB
/
example.ahk
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
; Example script
; Use a GetWindowRect Dll Call to get a RECT structure containing information on the Size of the window
; Use a GetCursorPos Dll Call to get a POINT structure containing mouse position
; Pass bits of each to a MoveWindow Dll Call
#NoEnv
#SingleInstance force
#include <_Struct>
#include <WinStructs>
Gui,+LastFound
Gui,Show,w100 h100 ;show window
hwnd:=WinExist() ;get window handle
/*
GetWindowRect
Docs: https://msdn.microsoft.com/en-us/library/windows/desktop/ms633519%28v=vs.85%29.aspx
Returns a RECT: https://msdn.microsoft.com/en-us/library/windows/desktop/dd162897(v=vs.85).aspx
A RECT is defined thus in WinStructs:
static RECT := "
(
LONG left;
LONG top;
LONG right;
LONG bottom;
)"
*/
RECT:=new _Struct(WinStructs.RECT) ;create structure
DllCall("GetWindowRect","Uint",hwnd,"Uint",RECT[]) ;get window position
RECT.right := RECT.right - RECT.left ;Set RECT.right to be the width
RECT.bottom := RECT.bottom - RECT.top ;Set RECT.bottom to be the height
/*
GetCursorPos
Docs: https://msdn.microsoft.com/en-us/library/windows/desktop/ms648390%28v=vs.85%29.aspx
Returns a POINT: https://msdn.microsoft.com/en-us/library/windows/desktop/dd162805(v=vs.85).aspx
A POINT is defined thus in WinStructs:
static POINT := "
(
LONG x;
LONG y;
)"
*/
/*
MoveWindow
Docs: https://msdn.microsoft.com/en-gb/library/windows/desktop/ms633534(v=vs.85).aspx
*/
POINT := new _Struct(WinStructs.POINT)
While DllCall("GetCursorPos","Uint",POINT[]) && DllCall("MoveWindow","Uint",hwnd,"int",POINT.x,"int",POINT.y,"int",RECT.right,"int",RECT.bottom,"Int",1){
Sleep, 10
}
return
Esc::
GuiClose:
Gui,Destroy
RECT:=""
ExitApp