 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
Hotfoot
Joined: 14 Sep 2005 Posts: 21
|
Posted: Fri Sep 16, 2005 6:56 pm Post subject: Hot Corners |
|
|
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
|
|
|
| Back to top |
|
 |
Dewi Morgan
Joined: 03 Oct 2005 Posts: 186
|
Posted: Tue Oct 04, 2005 3:20 am Post subject: |
|
|
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 Thu Jul 27, 2006 7:13 pm; edited 1 time in total |
|
| Back to top |
|
 |
faro Guest
|
Posted: Thu Jul 27, 2006 4:16 pm Post subject: |
|
|
| thanx |
|
| Back to top |
|
 |
itallmylove Guest
|
Posted: Thu May 15, 2008 11:14 am Post subject: |
|
|
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. |
|
| Back to top |
|
 |
ericisshort
Joined: 21 Jan 2009 Posts: 2
|
Posted: Wed Jan 21, 2009 5:01 pm Post subject: |
|
|
| Does anyone know how you would modify this script to work with multiple monitors? |
|
| Back to top |
|
 |
Krogdor
Joined: 18 Apr 2008 Posts: 1390 Location: The Interwebs
|
Posted: Thu Jan 22, 2009 12:58 am Post subject: |
|
|
@ 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 |
|
|
| Back to top |
|
 |
MonkeyBrains Guest
|
Posted: Mon Mar 30, 2009 11:31 pm Post subject: Doesn't work if you are using two monitors |
|
|
| 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. |
|
| Back to top |
|
 |
ericisshort
Joined: 21 Jan 2009 Posts: 2
|
Posted: Thu Apr 02, 2009 8:18 am Post subject: |
|
|
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:
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? |
|
| Back to top |
|
 |
hannaxbear Guest
|
Posted: Tue Jun 09, 2009 1:22 am Post subject: |
|
|
| Thanks so much for this! I love it! (: |
|
| Back to top |
|
 |
sunchess Guest
|
Posted: Sat Nov 21, 2009 9:08 am Post subject: |
|
|
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? |
|
| Back to top |
|
 |
Lewrex
Joined: 24 Dec 2009 Posts: 14
|
Posted: Sat Dec 26, 2009 1:04 am Post subject: Hot Corners in use |
|
|
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. |
|
| Back to top |
|
 |
Dinguz
Joined: 30 Oct 2009 Posts: 26
|
Posted: Mon Dec 28, 2009 3:21 am Post subject: Is, LEFT,RIGHT,UP,DOWN possible? |
|
|
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 Mon Feb 08, 2010 10:35 pm; edited 1 time in total |
|
| Back to top |
|
 |
Lewrex
Joined: 24 Dec 2009 Posts: 14
|
Posted: Mon Dec 28, 2009 9:30 pm Post subject: |
|
|
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. |
|
| Back to top |
|
 |
SoerenB
Joined: 25 Sep 2008 Posts: 10 Location: Germany
|
Posted: Fri Mar 12, 2010 1:21 pm Post subject: Hot Zones |
|
|
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 Thu Oct 07, 2010 8:47 am; edited 1 time in total |
|
| Back to top |
|
 |
Chicken Pie 4 Tea
Joined: 18 Aug 2009 Posts: 375 Location: holland
|
Posted: Thu Sep 30, 2010 8:16 pm Post subject: Re: Hot Zones |
|
|
the link doesnt point to HotZones! _________________ "Choose your parents wisely" |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|