I’ve shown this script around before. I should probably just give it up. But you know how it is, you get in the mood for sharing, and later on, much later on, you want to re-share, coz you’re a geek playing with lines of code, and you’re a social geek, too. So here’s an ahk script.

It’ll get you out of most anything that won’t go away otherwise. The reason there’s a delay, is in case the user changes their mind.

For some browsers, I’ve made it so that the script closes browser tabs, not the whole browser, not til the last tab is closed. I couldn’t figure out how to make Autohotkey not close browsers with the last tab; only in Firefox (far as I know), is there an internal setting that resists this command.

As for other programs/windows/dialogs, the script shows them the door if they won’t go away gracefully. Most of them, that is. Hope you enjoy.


~*$ESC::
settimer, click, -100 ; 0.10 seconds (?)
WinGetTitle, Title, A
KeyDown:=A_TickCount
Keywait Esc
if (A_TickCount-KeyDown > 650)
{
If title contains Internet Explorer, Nightly, Aurora, Firefox, Google Chrome, Opera
send, ^w
Else
winclose, %title%
}
Else
{
send, {ESC}
settimer,click, off
}

Click:
return