Windows 7 Forums
Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.


Windows 7: Key Customizing [Esc] to close Windows


01 Nov 2009   #1

Windows Seven x64
 
 
Key Customizing [Esc] to close Windows

Basically, all I want to be able to do is use the [ESC] button to close windows (ie Browsers,apps, games, anything that if selected and when a button is pressed will close it) in windows 7.

I always thought this would be good but is there anyway to make it do that from inside windows without some other software. If there isn't, then what other 3rd party programs can let me do this in Windows.

I have searched, not as heavy as I think i should, but all i keep seeing in Visual Basic and C++ programing, something I'm not good at.


If anyone can help it would be cool. It doesn't have to be [esc] but i would prefer it.



[Sorry if its in the wrong area, but this seemed to make sense, please feel free to move it if it does not belong here or you think it would be better in a another place on the forums. ]

My System SpecsSystem Spec
.

02 Nov 2009   #2

7 HP & ULT
 
 

Within Windows, I don't know how...but with AutoHotKey, it's easy.

AutoHotkey - Free Mouse and Keyboard Macro Program with Hotkeys and AutoText
My System SpecsSystem Spec
24 Oct 2011   #3

Windows 7 Home Premium 32bit
 
 

Please note that when using AHK (Auto Hotkey), the definition of a hotkey is a key combination (such as F6 or ALT-X or CTL-SHIFT-HOME) such that whenever you press that key combination the response is identical to some other keyboard combination.

Here is one definition of the ESCAPE key contained in an AHK script file (also known as an "AHK hotkey definition file") that causes the ESC key to behave identically as if you pressed the keyboard combination "ALT+F4".

ESCAPE::SendInput !{F4} ; close active window

Note that in the above definition:

1) everything to the right of the semicolon is a comment.

2) The above definition specifies that whenever the user presses the ESCAPE key, the effect is identical to that as if the user pressed and held down the ALT key and then pressed and released the F4 key and then released the ALT key.

There are many additional remarks I could make such as how to restore the original use of the ESCAPE key temporarily - especially since there are several different ways to define "temporarily".

1) One way to define "temporarily" is that you may wish to have the ESCAPE key used in its original way for just for a single keypress and then go back to its new meaning of "ALT-F4".

2) A second way is to stop using the ESCAPE key in this new way for a time, and then revert back to using it when you are ready. In this case you can define one hotkey that will cause the ESCAPE key to be used in this new way. Also, you can define a second hotkey that will cause the ESCAPE key to revert back to its original meaning.

In the following example, the hotkey SHIFT-F1 loads the AHK hotkey definition file "h1.ahk" which is equivalent to having the ESCAPE key defined as the sequence "ALT+F4".

Also the hotkey SHIFT-F2 loads the AHK hotkey definition file "h2.ahk" which is equivalent to having the ESCAPE key defined in its original way. In other words, pressing ALT+F1 causes the ESCAPE key to be used in a new manner which is equivalent to: everytime you press the ESCAPE key, the effect would be identical to your pressing ALT+F4.

Also, pressing ALT+F2 causes the ESCAPE key to be used in its original way. In this way, you have control over the use of the ESCAPE key. By pressing SHIFT+F1, you can cause the ESCAPE key to be used in its new manner (which is the same as pressing ALT+F4). You can use it in this new way for as long as you like and when you wish to revert back to its original usage, you can press SHIFT+F2 and that will ensure the pressing the ESCAPE key will have the same effect as it originally did.

-------------------------------------------------------------------------------------------

Please assume the text file "H1.AHK" contains the following three statements: This file is usually referred to as an AHK "Hotkey Definition File" or an AHK "Script File" and it contains the definitions of the hotkeys that will be used to affect their new meanings. I named this first file "H1" just to refer to the fact that it is a file of "(H)otkeys" and it is my first or primary file of AHK hotkeys.

+F1:: ; load script file h1.AHK
run %programfiles%\autohotkey\autohotkey.exe C:\AHK\h1.ahk
exitapp ; "exitapp" eliminates the requirement for any "Return" stmt

+F2:: ; load the new script file (H2.AHK)
run %programfiles%\autohotkey\autohotkey.exe C:\AHK\h2.ahk
exitapp ; "exitapp" eliminates the requirement for any "Return" stmt

ESCAPE::SendInput !{F4} ; close active window

;---------------------------------------------------------------------------------------

Please assume the text file "H2.AHK" contains the following two statements: This file is identical to "H1.AHK" except that it does not contain the third statement which defines the ESCAPE key to send the key sequence: "ALT + F4".

This file is usually referred to as an AHK "Hotkey Definition File" or an AHK "Script File" and it contains the definitions of the hotkeys that will be used to affect their new meanings. I named this second file "H2" to refer to the fact that it is a file containing "(H)otkeys" and it is my second such AHK definition file.

+F1:: ; load script file h1.AHK
run %programfiles%\autohotkey\autohotkey.exe C:\AHK\h1.ahk
exitapp ; "exitapp" eliminates the requirement for any "Return" stmt

+F2:: ; load the new script file (H2.AHK)
run %programfiles%\autohotkey\autohotkey.exe C:\AHK\h2.ahk
exitapp ; "exitapp" eliminates the requirement for any "Return" stmt

;---------------------------------------------------------------------------------------

In these examples, the hotkey SHIFT+F1 loads the script file named "h1.ahk" and
the hotkey SHIFT+F2 loads the script file named "h2.ahk".

+F1:: ; load script file h1.AHK
run %programfiles%\autohotkey\autohotkey.exe C:\AHK\h1.ahk
exitapp ; "exitapp" eliminates the requirement for any "Return" stmt


+F2:: ; load the new script file (H2.AHK)
run %programfiles%\autohotkey\autohotkey.exe C:\AHK\h2.ahk
exitapp ; "exitapp" eliminates the requirement for any "Return" stmt


Finally, please note that the script file "h1.ahk" and "h2.ahk" have both been saved in a folder named "C:\AHK"". This folder is not in any way a system folder. It is just used to save my AHK hotkey definition files.
My System SpecsSystem Spec
.


24 Oct 2011   #4

Windows 7 Home Premium 32bit
 
 

I'm sorry the above post is so long. I made it long in order to make it as clear as possible.

I hope those of you who will try to use AHK, will eventually come to see that it was a good choice and that it was the best way to explain how to use "hotkey definition files" as simply as possible.

I'd just like to say that AHK is the single best tool I have ever used with Windows and I can't imagine any other tool that could be as useful or as valuable to me than AHK.
My System SpecsSystem Spec
24 Oct 2011   #5

Microsoft Windows 7 Home Premium 64-bit 7601 Multiprocessor Free Service Pack 1
 
 

Jeez....is Alt-F4 so hard?
My System SpecsSystem Spec
24 Oct 2011   #6

Windows 7 Home Premium 32bit
 
 

Quote   Quote: Originally Posted by PeaB4YouGo View Post
Jeez....is Alt-F4 so hard?

You are correct, of course. No one would do this for just ALT-F4.
But, I'm pretty sure the OP is looking for a general technique that would include all manner of keys like ALT-F4.
In my main Windows AHK script file, I have hundreds of hotkey definitions that do all manner of useful things.
My System SpecsSystem Spec
Reply

 Key Customizing [Esc] to close Windows




Thread Tools



Similar help and support threads for2: Key Customizing [Esc] to close Windows
Thread Forum
How To Close (But Not Force Close) Program Automatically On A Schedule General Discussion
Audio Won't close In SyncUp when I close video file Music, Pictures & Video
Customizing Windows Explorer Customization
Customizing Windows Explorer? Customization
Customizing Windows Customization

Our Sites

Site Links

About Us

Find Us

Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd

All times are GMT -5. The time now is 07:41 PM.
Twitter Facebook Google+



Windows 7 Forums

Seven Forums Android App Seven Forums IOS App
  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33