Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Hot Corners


  • Please log in to reply
17 replies to this topic
Hotfoot
  • Members
  • 21 posts
  • Last active: Feb 15 2007 06:04 AM
  • Joined: 14 Sep 2005
I got the idea for this script from someone who wanted a boss/panic feature using only the mouse -- no mouse clicking or keys.

Moving the mouse to a corner of the screen triggers a command/s. Use modifier keys -- Alt, Shift, Control -- for additional commands. With modifier keys, commands are triggered when the modifier key is released.

This script is meant to be modified by the user for individual needs. I've included some examples of use. When using the script, make sure you watch your mouse placement to avoid accidentally triggering a Hot Corner. You might consider using a Hot Corner only with modifier keys if you frequently put your mouse near a corner during regular computer use.

Please post your comments or suggestions for improvement. Thanks.

; Hot Corners by Hotfoot
; September 16, 2005
;
; Activation: Move the mouse to different corners of the
; screen to trigger commands. The mouse is moved to the
; center of the screen before triggering the command to
; prevent triggering the command multiple times. If you want
; the mouse to be moved to a specific position after
; triggering a Hot Corner, modify the MouseMove position.
; If you want a command to be repeatedly triggered,
; remove the MouseMove command. It is possible to
; trigger multiple Hot Corners if you want by setting
; the mouse to move to a different Hot Corner after
; execution of one Hot Corner.
;
; Commands: Example commands are shown below. Hold down
; Shift, Control, or Alt keys for additional commands.
; Modify them for your needs.

; Timer to check mouse position
SetTimer, CheckMouse, 300

; Top Left Corner:
;  without keys:       (example of repeating command)
;  with Control key:   Show Desktop command
;  with Alt key:       (add your own command)
;  with Shift key:     (add your own command)
;
; Top Right Corner:
;  without keys:       Minimize window, give focus to next window
;  with Control key:   (add your own command)
;  with Alt key:       (add your own command)
;  with Shift key:     (add your own command)
;
; Bottom Left Corner:
;  without keys:       Close window
;  with Control key:   (add your own command)
;  with Alt key:       (add your own command)
;  with Shift key:     (add your own command)
;
; Bottom Right Corner:
;  without keys:       Left Mouse Click after 2 second delay
;  with Control key:   (add your own command)
;  with Alt key:       (add your own command)
;  with Shift key:     (add your own command)



#Persistent
#SingleInstance force

WinGetPos,,,Xmax,Ymax,ahk_class Progman  ; get desktop size

Xcenter := Xmax/2        ; Calculate center of screen
Ycenter := Ymax/2

T = 4   ; adjust tolerance value if desired

Xmax := Xmax - T   ; allow tolerance to mouse corner activation position
Ymax := Ymax - T

CheckMouse:                   ; check mouse position
CoordMode, Mouse, Screen
MouseGetPos, MouseX, MouseY

GetKeyState, SState, Shift
GetKeyState, AState, Alt
GetKeyState, CState, Control

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Commands for top left corner
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

if (MouseY < T and MouseX < T and CState = "U" and AState = "U" and SState = "U")
{
SoundBeep, 100, 10
SplashTextOn,,,Hot Corner Triggered
Sleep,500
SplashTextOff
}

if (MouseY < T and MouseX < T and CState = "D")
{
MouseMove, Xcenter, Ycenter
KeyWait, Control
send,#d
}

if (MouseY < T and MouseX < T and AState = "D")
{
MouseMove, Xcenter, Ycenter
KeyWait, Alt
Msgbox, Alt and Top Left
}

if (MouseY < T and MouseX < T and SState = "D")
{
MouseMove, Xcenter, Ycenter
KeyWait, Shift
Msgbox, Shift and Top Left
}

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Commands for top right corner
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

if (MouseY < T and MouseX > Xmax and CState = "U" and AState = "U" and SState = "U")
{
MouseMove, Xcenter, Ycenter
WinMinimize, A
Gosub, ActNextWindow
}

if (MouseY < T and MouseX > Xmax and CState = "D")
{
MouseMove, Xcenter, Ycenter
Keywait, Control
Msgbox, Control and Top Right
}

if (MouseY < T and MouseX > Xmax and AState = "D")
{
MouseMove, Xcenter, Ycenter
Keywait, Alt
Msgbox, Alt and Top Right
}

if (MouseY < T and MouseX > Xmax and SState = "D")
{
MouseMove, Xcenter, Ycenter
Keywait, Shift
Msgbox, Shift and Top Right
}

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Commands for bottom left corner
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

if (MouseY > Ymax and MouseX < T and CState = "U" and AState = "U" and SState = "U")
{
MouseMove, Xcenter, Ycenter
Msgbox, 4,, Close window?
IfMsgbox, Yes
{
WinClose,A
}
}

if (MouseY > Ymax and MouseX < T and CState = "D")
{
MouseMove, Xcenter, Ycenter
Keywait, Control
Msgbox, Control and Bottom Left
}

if (MouseY > Ymax and MouseX < T and AState = "D")
{
MouseMove, Xcenter, Ycenter
Keywait, Alt
Msgbox, Alt and Bottom Left
}

if (MouseY > Ymax and MouseX < T and SState = "D")
{
MouseMove, Xcenter, Ycenter
Keywait, Shift
Msgbox, Shift and Bottom Left
}

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Commands for bottom right corner
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

if (MouseY > Ymax and MouseX > Xmax and CState = "U" and AState = "U" and SState = "U")
{
MouseMove, Xcenter, Ycenter
SplashTextOn,,,Left Click where?
sleep,2000
SoundBeep, 100, 10    ; Audio signal
MouseClick,left
SplashTextOff
}

if (MouseY > Ymax and MouseX > XMax and CState = "D")
{
MouseMove, Xcenter, Ycenter
Keywait, Control
Msgbox, Control and Bottom Right
}

if (MouseY > Ymax and MouseX > XMax and AState = "D")
{
MouseMove, Xcenter, Ycenter
Keywait, Alt
Msgbox, Alt and Bottom Right
}

if (MouseY > Ymax and MouseX > XMax and SState = "D")
{
MouseMove, Xcenter, Ycenter
Keywait, Shift
Msgbox, Shift and Bottom Right
}

Return

ActNextWindow:      ; Get windows list and give focus to the top window
WinGet, WindowList, List
List =
Loop %WindowList%
{
WinUID := WindowList%A_Index%
WinGetTitle, WinTitle, ahk_id %WinUID%
If WinTitle <>
Break
}
WinActivate, ahk_id %WinUID%
Return


Dewi Morgan
  • Members
  • 191 posts
  • Last active: Jun 07 2015 04:02 AM
  • Joined: 03 Oct 2005
This is really nice :)

What I'd like is to be able to make the start menu (which I currently have set to "autohide") to only appear when I move to the bottom left corner, and a way for Trillian (an IM client) to pop up only when I go to the top left corner.

At the moment, they take up the whole bottom of the screen and the whole left of the screen respectively for their "hot zones". Which is rather irksome.

Can anyone think ofa way to do that?

[Edit]a thread where I answered my own question[/url], thinking I had only just realised that AHK could solve this problem: now I find I knew it all along!]
Yet another hotkeyer.

faro
  • Guests
  • Last active:
  • Joined: --
thanx

itallmylove
  • Guests
  • Last active:
  • Joined: --
Hello Hotfoot, thanks for your script but I don't know much about programming, and therefor i don't really understand the script you wrote. Can you or anyone else please edit the script for me? so if i move mouse to bottom right corner it run the screen saver ribbons.scr , move mouse to top left corner it show the desktop, move mouse to top right corner show the sidebar. All that without key pressed, just with mouse motion.
Thank you very much.

ericisshort
  • Members
  • 2 posts
  • Last active: Apr 03 2009 06:41 PM
  • Joined: 21 Jan 2009
Does anyone know how you would modify this script to work with multiple monitors?

Krogdor
  • Members
  • 1391 posts
  • Last active: Jun 08 2011 05:31 AM
  • Joined: 18 Apr 2008
@ ericisshort:
This should work, but I haven't tried it. Please tell me if there's anything wrong with it.

; Hot Corners by Hotfoot
; September 16, 2005
;
; Activation: Move the mouse to different corners of the
; screen to trigger commands. The mouse is moved to the
; center of the screen before triggering the command to
; prevent triggering the command multiple times. If you want
; the mouse to be moved to a specific position after
; triggering a Hot Corner, modify the MouseMove position.
; If you want a command to be repeatedly triggered,
; remove the MouseMove command. It is possible to
; trigger multiple Hot Corners if you want by setting
; the mouse to move to a different Hot Corner after
; execution of one Hot Corner.
;
; Commands: Example commands are shown below. Hold down
; Shift, Control, or Alt keys for additional commands.
; Modify them for your needs.

; Timer to check mouse position
SetTimer, CheckMouse, 300

; Top Left Corner:
;  without keys:       (example of repeating command)
;  with Control key:   Show Desktop command
;  with Alt key:       (add your own command)
;  with Shift key:     (add your own command)
;
; Top Right Corner:
;  without keys:       Minimize window, give focus to next window
;  with Control key:   (add your own command)
;  with Alt key:       (add your own command)
;  with Shift key:     (add your own command)
;
; Bottom Left Corner:
;  without keys:       Close window
;  with Control key:   (add your own command)
;  with Alt key:       (add your own command)
;  with Shift key:     (add your own command)
;
; Bottom Right Corner:
;  without keys:       Left Mouse Click after 2 second delay
;  with Control key:   (add your own command)
;  with Alt key:       (add your own command)
;  with Shift key:     (add your own command)



#Persistent
#SingleInstance force

;WinGetPos,,,Xmax,Ymax,ahk_class Progman  ; get desktop size
SysGet, Xmin, 76
SysGet, Ymin, 77
SysGet, Xmax, 78
SysGet, Ymax, 79
Xmax += Xmin
Ymax += Ymin

Xcenter := Xmax/2        ; Calculate center of screen
Ycenter := Ymax/2

T = 4   ; adjust tolerance value if desired

Xmax := Xmax - T   ; allow tolerance to mouse corner activation position
Ymax := Ymax - T
Xmin += T
Ymin += T

CheckMouse:                   ; check mouse position
CoordMode, Mouse, Screen
MouseGetPos, MouseX, MouseY

GetKeyState, SState, Shift
GetKeyState, AState, Alt
GetKeyState, CState, Control

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Commands for top left corner
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

if (MouseY < Ymin and MouseX < Xmin and CState = "U" and AState = "U" and SState = "U")
{
SoundBeep, 100, 10
SplashTextOn,,,Hot Corner Triggered
Sleep,500
SplashTextOff
}

else if (MouseY < Ymin and MouseX < Xmin and CState = "D")
{
MouseMove, Xcenter, Ycenter
KeyWait, Control
send,#d
}

else if (MouseY < Ymin and MouseX < Xmin and AState = "D")
{
MouseMove, Xcenter, Ycenter
KeyWait, Alt
Msgbox, Alt and Top Left
}

else if (MouseY < Ymin and MouseX < Xmin and SState = "D")
{
MouseMove, Xcenter, Ycenter
KeyWait, Shift
Msgbox, Shift and Top Left
}

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Commands for top right corner
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

else if (MouseY < ymin and MouseX > Xmax and CState = "U" and AState = "U" and SState = "U")
{
MouseMove, Xcenter, Ycenter
WinMinimize, A
Gosub, ActNextWindow
}

else if (MouseY < ymin and MouseX > Xmax and CState = "D")
{
MouseMove, Xcenter, Ycenter
Keywait, Control
Msgbox, Control and Top Right
}

else if (MouseY < ymin and MouseX > Xmax and AState = "D")
{
MouseMove, Xcenter, Ycenter
Keywait, Alt
Msgbox, Alt and Top Right
}

else if (MouseY < ymin and MouseX > Xmax and SState = "D")
{
MouseMove, Xcenter, Ycenter
Keywait, Shift
Msgbox, Shift and Top Right
}

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Commands for bottom left corner
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

else if (MouseY > Ymax and MouseX < xmin and CState = "U" and AState = "U" and SState = "U")
{
MouseMove, Xcenter, Ycenter
Msgbox, 4,, Close window?
IfMsgbox, Yes
{
WinClose,A
}
}

else if (MouseY > Ymax and MouseX < xmin and CState = "D")
{
MouseMove, Xcenter, Ycenter
Keywait, Control
Msgbox, Control and Bottom Left
}

else if (MouseY > Ymax and MouseX < xmin and AState = "D")
{
MouseMove, Xcenter, Ycenter
Keywait, Alt
Msgbox, Alt and Bottom Left
}

else if (MouseY > Ymax and MouseX < xmin and SState = "D")
{
MouseMove, Xcenter, Ycenter
Keywait, Shift
Msgbox, Shift and Bottom Left
}

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Commands for bottom right corner
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

else if (MouseY > Ymax and MouseX > Xmax and CState = "U" and AState = "U" and SState = "U")
{
MouseMove, Xcenter, Ycenter
SplashTextOn,,,Left Click where?
sleep,2000
SoundBeep, 100, 10    ; Audio signal
MouseClick,left
SplashTextOff
}

else if (MouseY > Ymax and MouseX > XMax and CState = "D")
{
MouseMove, Xcenter, Ycenter
Keywait, Control
Msgbox, Control and Bottom Right
}

else if (MouseY > Ymax and MouseX > XMax and AState = "D")
{
MouseMove, Xcenter, Ycenter
Keywait, Alt
Msgbox, Alt and Bottom Right
}

else if (MouseY > Ymax and MouseX > XMax and SState = "D")
{
MouseMove, Xcenter, Ycenter
Keywait, Shift
Msgbox, Shift and Bottom Right
}

Return

ActNextWindow:      ; Get windows list and give focus to the top window
WinGet, WindowList, List
List =
Loop %WindowList%
{
WinUID := WindowList%A_Index%
WinGetTitle, WinTitle, ahk_id %WinUID%
If WinTitle <>
Break
}
WinActivate, ahk_id %WinUID%
Return


MonkeyBrains
  • Guests
  • Last active:
  • Joined: --
I use two monitors with different resolutions and this screws up some of the geometry I think. for example, the Xmax is the width of both monitors added together and the Ymax is the greater of the two heights, which means that either the left or right lower corner is not accessible depending on which monitor is the shorter of the two.

ericisshort
  • Members
  • 2 posts
  • Last active: Apr 03 2009 06:41 PM
  • Joined: 21 Jan 2009
Sorry I forgot to reply to this earlier, but thanks krogdor for posting the edit. I am having the opposite problem as monkeybrains. If I go outside the boundaries of my first monitor on my second monitor, it calls the ahk script. I've illustrated the problem in the image below:
Posted Image

Monkeybrains, is your primary monitor larger than your second? If so, it looks to me as if the script is only taking the max and min from the y (or x if your monitors are side by side) from the two monitors while using the x (or y) max and min values from the primary monitor only.

I will look into fixing this over the weekend, but before I dive into it, can anyone more proficient in ahk tell me if this problem would be all that difficult to fix?

hannaxbear
  • Guests
  • Last active:
  • Joined: --
Thanks so much for this! I love it! (:

sunchess
  • Guests
  • Last active:
  • Joined: --
Guys, i think that thing with centering mouse cursor -- is really bad. Actually, I was even scared when my cursor jumps to center in my first try!

So, i want to get rid of this first. I remove those centerxcentery from script. But it begun to execute constanly, while mouse in corner. How to fix this? How to run command once when mouse in corner?

Lewrex
  • Members
  • 14 posts
  • Last active: Oct 15 2010 09:51 PM
  • Joined: 24 Dec 2009
This tool is great. I've combined it with a taskbar toggler and given credit to Hotfoot here:

http://rocketdock.co.../docklets/26821

Thanks for the code. It works very well.

Dinguz
  • Members
  • 26 posts
  • Last active: Jan 02 2011 03:17 AM
  • Joined: 30 Oct 2009
Is, LEFT,RIGHT,UP,DOWN possible...
as hotspots instead of just CORNERS?

8 directions = superior to 4 no?

If so please message me!

Lewrex
  • Members
  • 14 posts
  • Last active: Oct 15 2010 09:51 PM
  • Joined: 24 Dec 2009
Do you mean an option to make any corner trigger the hider (or all if you want)?

My latest update to it has that. I've replaced the file on the RocketDock link.

SoerenB
  • Members
  • 10 posts
  • Last active: Apr 14 2010 09:30 AM
  • Joined: 25 Sep 2008
Hi,

I borrowed heavily from HotFoots script, and made a HotZones thing, published here:

http://www.autohotke...pic.php?t=55631

Cheers
SoerenB

Chicken Pie 4 Tea
  • Members
  • 379 posts
  • Last active: Dec 12 2014 06:46 PM
  • Joined: 18 Aug 2009

Hi,

I borrowed heavily from HotFoots script, and made a HotZones thing, published here:

http://www.autohotke...opic.php?t=5563

Cheers
SoerenB


the link doesnt point to HotZones!
"Choose your parents wisely"