Skip to content

Instantly share code, notes, and snippets.

@KYDronePilot
Forked from dvtate/HotCorner.ahk
Last active May 12, 2024 05:02
Show Gist options
  • Save KYDronePilot/b3179f9e9840cb37c93e8bb691a8d27c to your computer and use it in GitHub Desktop.
Save KYDronePilot/b3179f9e9840cb37c93e8bb691a8d27c to your computer and use it in GitHub Desktop.
Hot Corners for Windows 10 using AutoHotKey
; ## What is it?
;
; An AutoHotKey script that replicates the "Hot Corners" feature of macOS on
; Windows
;
; ## How to use it?
;
; Modify the code in each `if` block (before the sleep command, which prevents
; duplicate triggers) for each corner below so it performs the desired action.
#Persistent
SetTimer, HotCorners, 0
return
HotCorners:
CoordMode, Mouse, Screen
; Get desktop size
WinGetPos, X, Y, Xmax, Ymax, Program Manager
; Adjust tolerance value if desired
T = 5
; Get the mouse position
MouseGetPos, MouseX, MouseY
; Check if the mouse is in any of the corners
TopLeftCorner := (MouseY < T and MouseX < T)
TopRightCorner := (MouseY < T and MouseX > Xmax - T)
BottomLeftCorner := (MouseY > Ymax - T and MouseX < T)
BottomRightCorner := (MouseY > Ymax - T and MouseX > Xmax - T)
if TopLeftCorner {
; Show desktop
Run, explorer.exe shell:::{3080F90D-D7AD-11D9-BD98-0000947B0257}
Sleep, 500
}
if TopRightCorner {
; Open task view
Run, explorer.exe shell:::{3080F90E-D7AD-11D9-BD98-0000947B0257}
Sleep, 500
}
if BottomLeftCorner {
Sleep, 500
}
if BottomRightCorner {
Sleep, 500
}
return
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment