-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHotCornersSAF.ahk
128 lines (115 loc) · 3.85 KB
/
HotCornersSAF.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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#Persistent
#SingleInstance Force
; Source:
; https://www.reddit.com/r/Windows10/comments/3ivdvu/how_could_i_activate_task_view_with_a_hot_corner/
; modified by S.A.Frye, 2016-03-21
; for Windows 10
; The following script can define hotcorners for any number of monitors arranged in any configuration.
; Horizontally arranged monitors work best
; Vertically arranged monitors may have some difficulty (read: over sensitivity since moving your mouse too far up puts it into Bottom*, not Top*), but should still work
Menu, Tray, Icon, %A_ScriptDir%\BlueArrow.ico, , 1
; TrayTip, TrayTip, Hot Corners for Windows 10, 10, 1
; ---------------------------------------
; USER CONFIGURABLE
; ---------------------------------------
global T = 5 ; Adjust tolerance if needed
global DEBUG := False
; Put your hotcorner actions here
; Open Task view
Action_TopLeft() {
Send, {LWin down}{Tab down}
Send, {LWin up}{Tab up}
}
; Peek at the desktop
Action_BottomRight() {
Send, {LWin down}{, down}
Send, {LWin up}{, up}
}
; Open the start menu
Action_BottomLeft() {
Send, {LWin down}
Send, {LWin up}
}
; Open the action centre
Action_TopRight() {
Send, {LWin down}{a down}
Send, {LWin up}{a up}
}
; ---------------------------------
; SETUP
; ---------------------------------
global ScreenArray := Object()
; Get the number of monitors
SysGet, NumMonitors, MonitorCount
; Insert a new empty array for each monitor
Loop %NumMonitors% {
ScreenArray.Insert(Object())
}
; For each monitor, get the dimensions as coordinates
for index, element in ScreenArray
{
; get monitor details for this index (These are 1 based indexes)
SysGet, Mon, Monitor, %index%
element.Insert(MonLeft)
element.Insert(MonTop)
element.Insert(MonRight)
element.insert(MonBottom)
}
GetCorner(x, y, cornerIndex, tolerance)
{
; loop through each monitor
for idx, elem in ScreenArray
{
if (cornerIndex == 0) { ; Top Left
; If statements are so it doesn't break the for loop on the first false. It will only return if true
if (x >= elem[1] and x <= elem[1] + tolerance) and (y >= elem[2] and y <= elem[2] + tolerance) {
return True
}
} else if (cornerIndex == 1) { ; Top Right
if (x >= elem[3] - tolerance and x <= elem[3]) and (y >= elem[2] and y <= elem[2] + tolerance) {
return True
}
} else if (cornerIndex == 2) { ; Bottom Right
if (x >= elem[3] - tolerance and x <= elem[3]) and (y >= elem[4] - tolerance and y <= elem[4]) {
return True
}
} else { ; Bottom Left
if (x >= elem[1] and x <= elem[1] + tolerance) and (y >= elem[4] - tolerance and y <= elem[4]) {
return True
}
}
}
}
; --------------------------
; MOUSE DETECTION LOOP
; --------------------------
SetTimer, HotCorners, 1500
return
HotCorners:
CoordMode, Mouse, Screen
MouseGetPos, MouseX, MouseY
if GetCorner(MouseX, MouseY, 0, T) { ; TopLeft
Action_TopLeft()
Sleep, 1000
if (DEBUG) {
Msgbox, Top Left %MouseX%,%MouseY%
}
} else if GetCorner(MouseX, MouseY, 1, T) { ; TopRight
Action_TopRight()
Sleep, 1000
if (DEBUG) {
Msgbox, Top Right %MouseX%,%MouseY%
}
} else if GetCorner(MouseX, MouseY, 3, T) { ; BottomLeft
Action_BottomLeft()
Sleep, 1000
if (DEBUG) {
Msgbox, Bottom Left %MouseX%,%MouseY%
}
} else if GetCorner(MouseX, MouseY, 2, T) { ; BottomRight
Action_BottomRight()
Sleep, 1000
if (DEBUG) {
Msgbox, Bottom Right %MouseX%, %MouseY%
}
}