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...