Hot Corners For Windows 10

Post your working scripts, libraries and tools
josiahayres
Posts: 2
Joined: 16 Feb 2016, 05:48
Google: +JosiahAyres

Hot Corners For Windows 10

16 Feb 2016, 06:12

This Script adds Mac and Linux Hot Corners capability to Windows 10.
This checks if the mouse is in a corner, and if it is the shortcut is fired.
It's partially based on another script that I found on the old AHK forum, but I have improved it as the old script would fire the shortcut key repeatedly if the mouse was moved to a corner and kept there.
It is also easier to reconfigure the actions in the corners because I majorly refactored the old script.

Code: Select all

#Persistent 				; Keeps script running persisitantly 
SetTimer, HotCorners, 0 		; HotCorners is name of timer, will be reset every 0 seconds until process is killed
return
HotCorners: 				; Timer content 
CoordMode, Mouse, Screen		; Coordinate mode - coords will be passed to mouse related functions, with coords relative to entire screen 

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"){
		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")
{
	Send, {LWin down}{tab down}
	Send, {LWin up}{tab up} 
	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
	}	
}
dsewq1LYJ
Posts: 113
Joined: 26 Aug 2014, 23:21

Re: Hot Corners For Windows 10

17 Feb 2016, 20:11

Sir...It's really a dark corner...
Holy jesus. It is incredibly useful...
User avatar
17kimv
Posts: 37
Joined: 21 Dec 2015, 20:15

Re: Hot Corners For Windows 10

22 Feb 2016, 23:40

I found it usefull, but I have 2 monitors, and it seems to glich between them, Still works great! Probably easy way to fix it.
Look MA! I am a programmer! :superhappy:
Maik
Posts: 2
Joined: 24 May 2016, 01:26

Re: Hot Corners For Windows 10

24 May 2016, 01:28

This... is... awesome. Wow!
Maik
Posts: 2
Joined: 24 May 2016, 01:26

Re: Hot Corners For Windows 10

24 May 2016, 02:02

I did a small modification because in some cases you need do pull a windows to a corner (in case you will set window size and position to quarter screen). If so then press and hold [ctrl] while pulling the window and it will snap into position instead of bringing up desktop view, start or whatever. Maybe someone find this useful:

Code: Select all

SetTimer, HotCorners, 0 ; HotCorners is name of timer, will be reset every 0 seconds until process is killed
return
HotCorners: ; Timer content 
CoordMode, Mouse, Screen ; Coordinate mode - coords will be passed to mouse related functions, with coords relative to entire screen 

 
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
  GetKeyState, controlKeyState, Control ; Function GetKeyState retrieves the current status ("U"p or "D"own) of a key
 
  T = 2 ; adjust tolerance value (pixels to corner) if desired
  
  if controlKeyState = U ; use hot corners only if control is not pressed
  {
    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"){
    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")
{
  Send, #{tab}
  Loop 
  {
    if ! IsCorner("TopLeft")
      break ; exits loop when mouse is no longer in the corner
  }
}
 
; Show Action Center
if IsCorner("TopRight")
{  
  Send, #a  
  Loop
  {
    if ! IsCorner("TopRight")
      break ; exits loop when mouse is no longer in the corner
  }  
}
 
; Press Windows 
if IsCorner("BottomLeft")
{  
  Send, {LWin}
  Loop
  {
    if ! IsCorner("BottomLeft")
      break ; exits loop when mouse is no longer in the corner
  }  
}

; Show Calendar
if IsCorner("BottomRight")
{  
  Send, #b{left}{enter}
  Loop
  {
    if ! IsCorner("BottomRight")
      break ; exits loop when mouse is no longer in the corner
  }  
}
(I added calendar in lower right corner too)
killah fhonics

Re: Hot Corners For Windows 10

28 Jul 2016, 17:19

Hey guys... how or where do I apply this script?
Any tutorial online?

Let me know.
Cheers.
josiahayres
Posts: 2
Joined: 16 Feb 2016, 05:48
Google: +JosiahAyres

Re: Hot Corners For Windows 10

28 Jul 2016, 22:13

1. You need to install https://autohotkey.com/download
2. Then download the script. It will probably download as script.txt
Or you can create a new text file on your desktop and copy paste the script from the browser into the new file.
3. Rename the file to script.ahk
4. Run script.ahk (double click)
5. To make the script automatically run on PC boot, copy the script.ahk file to C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup

That's it!
killah fhonics

Re: Hot Corners For Windows 10

29 Jul 2016, 13:08

Thank you sir!

Didnt realize AutoHotKey was a thing.... google search brought me here.
Cheers.
t4akawolf
Posts: 4
Joined: 30 Jul 2016, 03:30

Re: Hot Corners For Windows 10

30 Jul 2016, 12:16

What do I change to make it so that it registers an actual click to activate a Hot Corner?

EDIT: Figured it out myself after a lot of research and tinkering (I'm a newb). I changed the last part of the script to this:

Code: Select all

GetKeyState, LState, LButton

; Press Windows 
if (IsCorner("TopLeft") && LState = "D")
{	
	Send, {LWin down}
	Send, {LWin up}
	Loop
	{
		if ! IsCorner("TopLeft")
			break ; exits loop when mouse is no longer in the corner
	}	
}

; Show Desktop 
if (IsCorner("BottomLeft") && LState = "D")
{	
	Send, {LWin down}{d down}
	Send, {LWin up}{d up}
	Loop
	{
		if ! IsCorner("BottomLeft")
			break ; exits loop when mouse is no longer in the corner
	}	
}

; EMPTY
;if (IsCorner("TopRight") && LState = "D")
;{	
;	Send, {...}
;	Send, {...}
;	Loop
;	{
;		if ! IsCorner("TopRight")
;		break ; exits loop when mouse is no longer in the corner
;	}
;}

; Show Action Center
if (IsCorner("BottomRight") && LState = "D")
{	
	Send, {LWin down}{a down}
	Send, {LWin up}{a up}
	Loop
	{
		if ! IsCorner("BottomRight")
		break ; exits loop when mouse is no longer in the corner
	}
}
Hope someone finds it useful. Note that the Action for TopRight is empty. Fill it in if you have a use for it (by removing the semi-colons and assigning commands to Send), or just leave it be. I didn't use that corner because it would interfere with Closing maximized windows; if you do end up using TopRight, I suggest you remove && LState = "D" from it first, and using it how OP intended it.

P.S.: If the positions and corresponding Hot Actions seem weird to anyone, it's because I have my Taskbar vertical and on the left edge of my screen. So, my Start button used to be (before I hid it, now that I have no use for it) in the top left corner, and my Show Desktop button used to be in the bottom left.
hasantr
Posts: 92
Joined: 05 Apr 2016, 14:18

Re: Hot Corners For Windows 10

03 Feb 2017, 12:57

When he goes to the corner, he works right away. Can it be done in a way that will take action after waiting a little?
Thank you. :)
Guest

Re: Hot Corners For Windows 10

10 Jan 2018, 21:03

you sir...YOU...are my hero of the month!
Thank you so much
User avatar
Delta Pythagorean
Posts: 423
Joined: 13 Feb 2017, 13:44
GitHub: DelPyth
Location: Equestria

Re: Hot Corners For Windows 10

11 Jan 2018, 10:34

I actually have a simplified version of this with customization in what it can do on my laptop, give me an hour or so and I can get it right in here!
User avatar
Delta Pythagorean
Posts: 423
Joined: 13 Feb 2017, 13:44
GitHub: DelPyth
Location: Equestria

Re: Hot Corners For Windows 10

12 Jan 2018, 19:34

Here it is, the Hotcorner script that's easy to manage!
Hope you find it useful!

Code: Select all


#NoEnv
#SingleInstance, Force
#MaxThreadsPerHotkey, 1
#KeyHistory, 0
#Persistent
ListLines, Off
SetBatchLines -1
SetWinDelay, -1
SetMouseDelay, -1
SetKeyDelay, -1, -1
SetTitleMatchMode, 3
DetectHiddenWindows, On
SetWorkingDir, %A_ScriptDir%
SendMode, Input
CoordMode, Mouse, Screen

CornerList :=
(LTrim Join
	{
		"TopLeft":		"TopLeft",
		"TopRight":		"TopRight",
		"BottomRight":	"BottomRight",
		"BottomLeft":	"BottomLeft"
	}
)
SetTimer, HotCorners, 10
Return

HotCorners:
	For Each, Item in CornerList
		CheckCorner(Each, Item)
	Return

TopLeft:
TopRight:
BottomLeft:
BottomRight:
	MsgBox, % A_ThisLabel
	Return

IsCorner(CornerID) {
	Static T := 10, IsMouse := {}
	Mouse := MouseGetPos()
	IsMouse.TopLeft			:= (Mouse.Y < T) && (Mouse.X < T)
	IsMouse.TopRight		:= (Mouse.Y < T) && (Mouse.X > (A_ScreenWidth - T))
	IsMouse.BottomLeft		:= (Mouse.Y > (A_ScreenHeight - T)) && (Mouse.X < T)
	IsMouse.BottomRight		:= (Mouse.Y > (A_ScreenHeight - T)) && (Mouse.X > (A_ScreenWidth - T))

	Return, IsMouse[CornerID]
}

CheckCorner(Name, LabelOrFunc) {
	If (IsCorner(Name)) {
		If (IsLabel(LabelOrFunc))
			GoSub, % LabelOrFunc
		Else If (IsFunc(LabelOrFunc))
			%LabelOrList%(Name)
		Else
			Throw Exception("This is not a function!")
		Loop {
			If (!IsCorner(Name))
				Break
		}
	}
	Return
}

MouseGetPos(Options := 3) {
	MouseGetPos, X, Y, Win, Ctrl, % Options
	Return, {X: X, Y: Y, Win: Win, Ctrl: Ctrl}
}
EDIT: Minor changes
User avatar
king-of-hearts
Posts: 30
Joined: 01 Oct 2017, 06:29

Re: Hot Corners For Windows 10

17 Jan 2018, 13:57

Cool!
https://autohotkey.com/boards/viewtopic.php?f=6&t=38707 - MS Access Manager - SQL Query: Incredible tool for MS Access/SQL Queries on the fly!!
andrewkondrat

Re: Hot Corners For Windows 10

10 Mar 2018, 11:46

With delay and example of two corners. If you restart it, then there is no duplication

Code: Select all

; Screen
CoordMode, Mouse, Screen
SysGet, VirtualWidth, 78
SysGet, VirtualHeight, 79
; Temp Variables
BLCounter := 0
BRCounter := 0
; Kill previous
Send {Ctrl down}{Shift down}{Alt down}{LWin down}{Ctrl up}{Shift up}{Alt up}{LWin up}
Sleep 200
; While SHIT + ALT + CTRL + LWIN pressed
While Not(GetKeyState("Ctrl", "P") And  GetKeyState("Alt", "P") And GetKeyState("LWin", "P") And GetKeyState("Shift", "P"))
	{
	; Read mouse
	MouseGetPos, MouseX, MouseY
	
	;Left corner
	If (MouseX = 0) And (MouseY = VirtualHeight - 1)
		{
		Sleep, 100
		BLCounter := BLCounter + 100
		If BLCounter >= 300
			{
			; Send key sequence
			Send, #{Tab}
			While (MouseX = 0) And (MouseY = VirtualHeight - 1)
				{
				MouseGetPos, MouseX, MouseY
				}
			}
		}
	Else
		{
		BLCounter := 0
		}
		
	If (MouseX = VirtualWidth - 1) And (MouseY = VirtualHeight - 1)					
		{
		Sleep, 100
		BRCounter := BRCounter + 100
		If BRCounter >= 300
			{
			; Send key sequence
			Send, #d
			While (MouseX = VirtualWidth - 1) And (MouseY = VirtualHeight - 1)				
				{
				MouseGetPos, MouseX, MouseY								
				}
			}
		}
	Else
		{
		BRCounter := 0
		}
	}

Return to “Scripts and Functions”

Who is online

Users browsing this forum: vbmark and 42 guests