DonationCoder.com forum
 
Read-only archive. This is a static copy of the DonationCoder.com forum. Reading and searching work as before; logging in, posting and private messages do not.
Archive of 2026-10-21 · About this archive · Main site

Author Topic: DONE: ESC closes Windows Explorer (AHK)  (Read 7,187 times)

brotherS

  • Master of Good Ideas
  • Honorary Member
  • Joined in 2005
  • **
  • Posts: 2,261
DONE: ESC closes Windows Explorer (AHK)
« on: October 08, 2006, 12:00 PM »
Hi!

I came up with this little script to easily close Windows Explorer windows:

Code
#Persistent
$ESC::
  Send, {ESC}
If WinActive("ahk_class ExploreWClass")
  Send !{F4}
return

It works great, it just has one problem: you can't use ESC anymore to abort renaming of files, like when you accidentally deleted important parts of the file name and can't just press enter to "OK" the change.

So I need some way to 'only send Alt+F4 (!{F4}) if ESC is pressed twice within one second'. Got any ideas for a smart solution? I bet you do!

:Thmbsup:
Thank you.
« Last Edit: October 08, 2006, 04:27 PM by brotherS »

jgpaiva

  • Artificial Idiocy
  • Global Moderator
  • Joined in 2006
  • *****
  • Posts: 4,727
    • Cody Award
    • Participated in NANY Challenge Once
    • Coding Snacks
    • Portugal Inhabitant
    • Linux User
Re: IDEA: ESC closes Windows Explorer (AHK)
« Reply #1 on: October 08, 2006, 12:06 PM »
Something in this terms might solve it:

Code
ESCflag := false

$ESC:
  Send,{ESC}
  IF WinActive("ahk_class ExploreWClass")
    IF ESCflag
      send,!{F4}
    else
    {
      ESCflag := True
      settimer,SomeTimer,1000
    }
  return

SomeTimer:
  settimer,SomeTimer,off
  ESCflag := false
  return
Warning: untested code. But should work ;)

kimmchii

  • Honorary Member
  • Joined in 2005
  • **
  • Posts: 360
Re: IDEA: ESC closes Windows Explorer (AHK)
« Reply #2 on: October 08, 2006, 12:08 PM »
i use this:
Code
Opt("WinTitleMatchMode", 4)
while WinExists("classname=CabinetWClass", "")
   Winclose("classname=CabinetWClass", "")
wend
edit: unrelated code, sorry lol.
If you find a good solution and become attached to it, the solution may become your next problem.
~Robert Anthony
« Last Edit: October 08, 2006, 12:12 PM by kimmchii »

brotherS

  • Master of Good Ideas
  • Honorary Member
  • Joined in 2005
  • **
  • Posts: 2,261
Re: IDEA: ESC closes Windows Explorer (AHK)
« Reply #3 on: October 08, 2006, 12:14 PM »
Thanks jgpaiva, works!  :up:

kimmchii: what does that do: close *all* Windows Explorer windows?
Thank you.

kimmchii

  • Honorary Member
  • Joined in 2005
  • **
  • Posts: 360
Re: IDEA: ESC closes Windows Explorer (AHK)
« Reply #4 on: October 08, 2006, 12:55 PM »
yes, close *all* Windows Explorer  :D
If you find a good solution and become attached to it, the solution may become your next problem.
~Robert Anthony

Original address: https://www.donationcoder.com/forum/index.php?topic=5669.0