AutoHotkey Community

It is currently May 27th, 2012, 11:18 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 19 posts ]  Go to page Previous  1, 2
Author Message
 Post subject:
PostPosted: November 13th, 2006, 7:11 am 
Offline

Joined: October 1st, 2005, 9:55 pm
Posts: 775
Location: Texas, USA
badmojo wrote:
jballi:
i've been trying to construct a script akin to yours here.

but since i realize that you had started earlier than me, i was wondering you have a working script available that can be used in daily environment. especially, when dealing with apps that use Escape intrinsically. i'm still tinkering but the results are not that good..

I don't know the exact problems you are experiencing but I'm guessing that you're probably trying to cram a lot a program with different "Escape" key requirements into the single "Escape To Close" group.

To simplify things, you might want to create a separate AHK group for every Escape key requirement and then create hotkey code for each group. For my personal use, I've created the following AHK groups:
    $EscapeToClose - Escape To Close
    $DEscapeToClose - Double Escape To Close
    $EscapeToHide - Escape To Hide
    $EscapeToMinimize - Escape To Minimize

The $EscapeToClose group follows the example I posted at the top. This group is designed to be used for applications where you want to close the application when the Escape key is pressed once.

For applications that "use Escape intrinsically", I created the $DEscapeToClose group that will close the application when the Escape key is pressed twice. I put EncSpot and Windows Calculator into this group. Both of these programs use the Escape key to perform a valuable function. When I press the Escape key when using these applications, the program does what it is supposed to do. Note the use of the "native" designation ("~") in the hotkey definition (below). However, if I press the Escape key twice in a row (within 350 ms), the program is closed.

The other groups are self explanatory (I hope).

The following are examples of the code that will process these groups:
Code:
;[===========================]
;[  Escape                   ]
;[  [Escape To Close Group]  ]
;[===========================]
#IfWinActive ahk_group $EscapeToCloseGroup
Escape::
#IfWinActive

;-- Close active window
WinClose
return



;[============================]
;[  Escape                    ]
;[  [DEscape To Close Group]  ]
;[============================]
#IfWinActive ahk_group $DEscapeToCloseGroup
~Escape::
#IfWinActive

;-- Double Escape?
if (A_ThisHotKey=A_PriorHotKey)
    if A_TimeSincePriorHotkey<350
        WinClose

return



;[==========================]
;[  Escape                  ]
;[  [Escape To Hide Group]  ]
;[==========================]
#IfWinActive ahk_group $EscapeToHideGroup
Escape::
#IfWinActive

;-- Hide active window
WinHide
return



;[==============================]
;[  Escape                      ]
;[  [Escape To Minimize Group]  ]
;[==============================]
#IfWinActive ahk_group $EscapeToMinimizeGroup
Escape::
#IfWinActive

;-- Minimize active window
WinMinimize
return

You can create a group to represent any unique requirement. The only thing you don't want to do is to add a program to more than one of these "Escape to ..." groups.

I hope this helps. If not, make a noise. I'm sure that we can get you where you need to go.

Them be my thoughts...


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Re: Press Escape twice
PostPosted: November 24th, 2007, 2:39 am 
emisjerry wrote:
Since the normal Escape has its own functionality, could I press Escape twice to close the window. Using this method, i can ignore the group or file to identify which need to be closed.

Is there any way to press a key twice? ~Esc & Esc:: cannot work....


I just use

Code:
#ESC:: send !{F4}


that is WindowsKey + Esc, that way escape still works as normal.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: November 24th, 2007, 3:23 am 
Offline

Joined: February 14th, 2005, 4:05 pm
Posts: 4710
Location: Boulder, CO
I use the following script. If you double hit ESC, it closes the active window. In Firefox or IE7 it first closes the current tab, and if there is no more tab, it closes the window. Double-ESC is faster than Win-ESC, because you don’t need two fingers and don’t need to look down to the keyboard.
Code:
~Esc::
   WinGetClass Class, A
   If (A_ThisHotKey = A_PriorHotkey && A_TimeSincePriorHotkey < 999)
      If Class in MozillaUIWindowClass,IEFrame
         Send ^w
      Else
         Send !{F4}
Return


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 10th, 2008, 5:23 am 
Offline

Joined: November 9th, 2008, 12:33 am
Posts: 14
Another idea for the escape button is to use it as a save & close button, not just a close button. This eliminates the step of manually pressing ctrl + s, and makes it easier for me to quickly work with my todo list and AHK scripts in notepad. I accidentally disabled this once when editing the script, and I kept hitting esc over and over, thinking, "Why won't it work?!" Hehe. I use it a lot, never realized how much until it wasn't working.
Like so:
Code:
#IfWinActive, ahk_class Notepad
esc::
Send,^s
sleep 0500
WinClose
Return

I just make new entries for each window class I want to use this for.


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: nomissenrojb, Rajat, Yahoo [Bot] and 56 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