Many releases ago, IrfanView included a simple but effective option for closing the application quickly: the Escape key. For many IrfanView users like myself, the Escape key is a perfect way to quickly close the application. I primarily use the program to view 1 or 2 images and then hit the Escape key to get it out way.
Anywho, I use a couple of drag-and-drop utilities that can only be closed with context menu or with a key-combination. As I was grumbling as to how much a pain-in-the-butt is was to close these boogers, I thought, "Why not close these with the Escape key just like IrfanView?" Then as I was coding for those guys, I thought, "Hey! There are probably a bunch of other programs that can be closed this way!"
There are 2 steps to the process. The first step is to define the group. Here's an example:
GroupAdd $EscapeGroup,ahk_class lamedropXPd GroupAdd $EscapeGroup,MP3Gain GroupAdd $EscapeGroup,ahk_class oggdropWin GroupAdd $EscapeGroup,QuickPar -When you discover a new program that can/should be Escape closed, just add it to the group.
For my personal use I'm thinking about putting the windows in this group into a configuration file so that I can add/delete windows/classes to/from the group without changing the AHK code. I'm still not sure whether it merits the trouble.
The second step is to define the hotkey. Here's an example:
#IfWinActive ahk_group $EscapeGroup Escape:: #IfWinActive ;-- Close window WinClose ;-- Return to sender return
IMHO, not applications are good candidates for a quick close. Any program where you could possibly lose work, settings, or time probably shouldn't be closed without additional thought or action.
This is certainly not a new or original idea but the recently introduced #IfWinActive directive has made this task much easier to code for. Thank you Chris! I've included this code just in case you think it's a good idea too.