-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathHotCorners.ahk
133 lines (103 loc) · 3.09 KB
/
HotCorners.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
129
130
131
132
133
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
#singleinstance force
#Persistent ; Keeps script running persisitantly
SetTimer, HotCorners, 0 ; HotCorners is name of timer, will be reset every 0 seconds until process is killed
global activeSwit := false
CheckMonitors() ; Check the number of monitors. Disable hotcorners in a multi-monitor environment.
{
SysGet, numMonitors, MonitorCount
if numMonitors > 1
{
SetTimer, HotCorners, Off
}
else
{
SetTimer, HotCorners, 0
}
}
SetTimer, CheckMonitors, 1000 ; Call the CheckMonitors function at an interval of 1 second
HotCorners: ; Timer content
CoordMode, Mouse, Screen ; Coordinate mode - coords will be passed to mouse related functions, with coords relative to entire screen
LButtonIsDown := GetKeyState("LButton", "P")
if LButtonIsDown
{
activeSwit := false
}
IsCorner(cornerID)
{
WinGetPos, X, Y, Xmax, Ymax, Program Manager ; get desktop size
MouseGetPos, MouseX, MouseY ; Function MouseGetPos retrieves the current position of the mouse cursor
T = 5 ; adjust tolerance value (pixels to corner) if desired
CornerTopLeft := (MouseY < T and MouseX < T) ; Boolean stores whether mouse cursor is in top left corner
CornerTopRight := (MouseY < T and MouseX > Xmax - T) ; Boolean stores whether mouse cursor is in top right corner
CornerBottomLeft := (MouseY > Ymax - T and MouseX < T) ; Boolean stores whether mouse cursor is in bottom left corner
CornerBottomRight := (MouseY > Ymax - T and MouseX > Xmax - T) ; Boolean stores whether mouse cursor is in top left corner
if (cornerID = "TopLeft"){
RButtonIsDown := false
return CornerTopLeft
}
else if (cornerID = "TopRight"){
return CornerTopRight
}
else if (cornerID = "BottomLeft"){
return CornerBottomLeft
}
else if (cornerID = "BottomRight") {
return CornerBottomRight
}
}
; Show Task View (Open Apps Overview)
if IsCorner("TopLeft")
{
if !activeSwit
{
Send, {Lalt down}{LCTRL down}{tab down}
send, {lalt up} {lctrl up}{tab up}
sleep 55
send, {left}
activeSwit := true
}else
{
send {space}
activeSwit := false
}
Loop
{
if ! IsCorner("TopLeft")
break ; exits loop when mouse is no longer in the corner
}
}
; Show Action Center
if IsCorner("TopRight")
{
Send, {LWin down}{a down}
Send, {LWin up}{a up}
Loop
{
if ! IsCorner("TopRight")
break ; exits loop when mouse is no longer in the corner
}
}
; Press Windows
if IsCorner("BottomLeft")
{
;Send, {LWin down}
;Send, {LWin up}
Loop
{
if ! IsCorner("BottomLeft")
break ; exits loop when mouse is no longer in the corner
}
}
; Show Desktop
if IsCorner("BottomRight")
{
;Send, {LWin down}{d down}
;Send, {LWin up}{d up}
Loop
{
if ! IsCorner("BottomRight")
break ; exits loop when mouse is no longer in the corner
}
}