Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

First of all, let me point out that I'm certainly familiar with the age-old Alt+F4 shortcut, so that's not exactly what I want.

Probably half the programs I use on a regular basis have the Ctrl+W shortcut that closes the current tab (in browser), spreadsheet (in Excel), or text file (in Notepad++) - just a few examples. I've grown so accustomed to using Ctrl+W that it really irks me when a program does not utilize the same hotkeys.

I've never used AutoHotkey before, but I've seen plenty of articles on its usefulness. Is this task something within the scope of an AutoHotkey script? I would want the shortcut to close the current tab or sub-window, but then close the current program after the final tab is closed.

In Chrome, this is default behavior, but I haven't seen the same in too many other applications. I love the functionality, though, and would like to port it to all Windows apps.

share|improve this question
    
Do you have a specific program that you are looking to make work this way? I just tested and ctrl+w closed the current windows on Windows 7 in Word 2010, Excel 2010, Visio 2010, and Adobe reader. This could also be a feature of Windows 7 itself, but that is a complete guess. –  Zac Garrett Oct 21 '10 at 17:37
    
I am running Windows 7 and I know for sure this shortcut does not work on the applications I mentioned. However, I'm also using Office 2007 so it sounds like that's a feature they added in 2010. I'm trying to actually use this functionality in AutoCAD 2011, Notepad++, and PDF-XChange Viewer primarily. –  NoCatharsis Oct 21 '10 at 17:42

2 Answers 2

up vote 1 down vote accepted

In AutoHotkey you can easily remap Ctrl+W per application. For instance in EditPlus Ctrl+F4 closes an MDI window.

#IfWinActive EditPlus - 
^w::Send ^{F4}

If say a menu's Close doesn't have a hotkey, you can use AltFC to open the File menu and use the accelerator.

If that fails you can use ControlClick (e.g. on a toolbar icon).
If that fails you can use PostMessage/SendMessage.

A more advanced script could certainly close the application after its children, if it doesn't already do so.

share|improve this answer

I can attest that in windows 7 the desired shortcut (Ctrl+W) work differently according to each program. In office 2003 (closes opened doc, not the window), windows explorer (closes the window), firefox (closes the tab and them the window if it's the last tab, like Chrome), notepad++ (close the tab)...

You can certainly remap any shortcut using autohotkey for closing, but implementing this new functionality present in Firefox and Chrome, in all the programs seems not possible because it is program related not Windows related like the regular ALF+F4

This site is a great place to check for examples and see what can be done with autohotkey. Good luck

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.