AutoHotkey Community

It is currently May 27th, 2012, 8:53 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 18 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Hot Corners
PostPosted: September 16th, 2005, 7:56 pm 
Offline

Joined: September 14th, 2005, 5:21 am
Posts: 21
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.

Code:
; 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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 4th, 2005, 4:20 am 
Offline

Joined: October 3rd, 2005, 2:42 am
Posts: 186
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: I'd forgotten I had asked this :) I'm coming across it a few days after I posted a thread where I answered my own question, thinking I had only just realised that AHK could solve this problem: now I find I knew it all along!]

_________________
Yet another hotkeyer.


Last edited by Dewi Morgan on July 27th, 2006, 8:13 pm, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 27th, 2006, 5:16 pm 
thanx


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: May 15th, 2008, 12:14 pm 
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.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: January 21st, 2009, 6:01 pm 
Offline

Joined: January 21st, 2009, 5:50 pm
Posts: 2
Does anyone know how you would modify this script to work with multiple monitors?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 22nd, 2009, 1:58 am 
Offline

Joined: April 18th, 2008, 7:57 am
Posts: 1390
Location: The Interwebs
@ ericisshort:
This should work, but I haven't tried it. Please tell me if there's anything wrong with it.

Code:
; 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


Report this post
Top
 Profile  
Reply with quote  
PostPosted: March 31st, 2009, 12:31 am 
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.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: April 2nd, 2009, 9:18 am 
Offline

Joined: January 21st, 2009, 5:50 pm
Posts: 2
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:
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?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 9th, 2009, 2:22 am 
Thanks so much for this! I love it! (:


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: November 21st, 2009, 10:08 am 
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?


Report this post
Top
  
Reply with quote  
 Post subject: Hot Corners in use
PostPosted: December 26th, 2009, 2:04 am 
Offline

Joined: December 24th, 2009, 2:21 pm
Posts: 14
This tool is great. I've combined it with a taskbar toggler and given credit to Hotfoot here:

http://rocketdock.com/addon/docklets/26821

Thanks for the code. It works very well.


Report this post
Top
 Profile  
Reply with quote  
PostPosted: December 28th, 2009, 4:21 am 
Offline

Joined: October 30th, 2009, 1:03 am
Posts: 26
Is, LEFT,RIGHT,UP,DOWN possible...
as hotspots instead of just CORNERS?

8 directions = superior to 4 no?

If so please message me!


Last edited by Dinguz on February 8th, 2010, 11:35 pm, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 28th, 2009, 10:30 pm 
Offline

Joined: December 24th, 2009, 2:21 pm
Posts: 14
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Hot Zones
PostPosted: March 12th, 2010, 2:21 pm 
Offline

Joined: September 25th, 2008, 9:33 am
Posts: 10
Location: Germany
Hi,

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

http://www.autohotkey.com/forum/viewtopic.php?t=55631

Cheers
SoerenB


Last edited by SoerenB on October 7th, 2010, 9:47 am, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject: Re: Hot Zones
PostPosted: September 30th, 2010, 9:16 pm 
Offline

Joined: August 18th, 2009, 12:07 pm
Posts: 375
Location: holland
SoerenB wrote:
Hi,

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

http://www.autohotkey.com/forum/viewtopic.php?t=5563

Cheers
SoerenB


the link doesnt point to HotZones!

_________________
"Choose your parents wisely"


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 18 posts ]  Go to page 1, 2  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: IsNull, tomoe_uehara, Xx7 and 12 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group