-
Notifications
You must be signed in to change notification settings - Fork 71
/
class_Mouse.ahk
97 lines (79 loc) · 1.79 KB
/
class_Mouse.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
;#NoTrayIcon
;#SingleInstance force
/**
Class Mouse
*/
Class Mouse {
pos_saved := {"x":"","y":"","coord_mode":""}
__New(){
}
/** get number of monitor where is cursor
*/
monitorNumber(){
;CoordMode, Mouse, Screen
;MouseGetPos, $mouse_x, $mouse_y
$mouse_pos := this.getPosition()
return % Monitor().getMonitorByPos($mouse_pos.x)
}
/** getPos
*/
getPos($CoordMode:="Screen"){
CoordMode, Mouse, %$CoordMode%
MouseGetPos, $mouse_x, $mouse_y
return % {"x":$mouse_x, "y":$mouse_y}
}
/** posSave
*/
posSave(){
;this.pos_saved.coord_mode := A_CoordModeMouse
$coord_mode_tmp := A_CoordModeMouse
CoordMode, mouse, screen
MouseGetPos, $mouse_x, $mouse_y
this.pos_saved.x := $mouse_x
this.pos_saved.y := $mouse_y
;CoordMode, Mouse, % this.pos_saved.coord_mode
CoordMode, Mouse, %$coord_mode_tmp%
return this
}
/** posRestore
*/
posRestore(){
$coord_mode_tmp := A_CoordModeMouse
CoordMode, Mouse, Screen
MouseMove, % this.pos_saved.x, % this.pos_saved.y, 0
CoordMode, Mouse, %$coord_mode_tmp%
return this
}
}
/**
CALL CLASS FUNCTION
*/
Mouse(){
return % new Mouse()
}
/*
-----------------------------------------------
TEST FUNCTIONS
-----------------------------------------------
*/
/** monitorNumber
*/
monitorNumber(){
$mouse_monitor := Mouse().monitorNumber()
dump($mouse_monitor, "mouse_monitor", 1)
}
/*
-----------------------------------------------
RUN TEST
-----------------------------------------------
*/
;monitorNumber()
/*
-----------------------------------------
OLD FUNCTIONS
-----------------------------------------
*/
;;; ------------------------------------------------------------------
Mouse_getMonitorNumber(){
MsgBox,262144,, "Function Mouse_getMonitorNumber() IS DEPRECATED, USE Mouse().monitorNumber()"
}