How can I change the shortcut for closing windows from Alt+F4 to Ctrl+W in windows.
Keep in mind that Ctrl+W is used for other things, e.g. in Notepad², it enables word wrap.
I think that even an AutoHotkey beginner can do this. The script is as follows:
But what if you just wanted to close a Word document or a Firefox tab (when Ctrl+W is used as a hotkey), not the whole application?
The ideas above are quite good ones and they bring up good points, and learning how to use AutoHotKey is a great idea, as a general matter. You can download the software via http://ahkscript.org/download/ahk-install.exe which is directly linked at the homepage of http://www.autohotkey.com/ .
Keep in mind, that while the default keystroke combination of Alt+F4 will close the ENTIRE program (e.g., Firefox, MSWord, MSExcel) which is sometimes precisely what you want to do, the default keystroke combination of Ctrl+W allows you to close only a certain subwindow or tab of certain programs (e.g., Firefox, MSWord, MSExcel) which is sometimes all you might really intend or want. If you implement an Autohotkey idea like these fellows are suggesting, then BOTH aforementioned keystroke combinations will close the ENTIRE program.
Something else to mention? If you're a novice/sub-intermediate computer user, downloading and using Autohotkey by yourself MIGHT seem a little overwhelming. IF this is the case, then head over to the Autohotkey forums (also at http://www.autohotkey.com/ ), tell them that fellows from superuser.com sent you, request that they provide you with an AHK script that does what you're requesting here, AND ask them (and tell them you're quoting me-- in fact, link them to this superuser thread) to compile the resultant AHK script into a *.exe file. Then, once they give it to you, thank them, and put the new *.exe file in your Windows startup folder.
Also, you can try to talk to them via the #ahk IRC channel on Freenode.
**actually, just a quick follow-up query for the lads above such as @Mikel ... If a person makes an AHK-script that replaces a default keystroke combination like Alt-F4 (as might be requested in this place), are you SURE that the new keystroke combination will replace the old, default one? Just want to verify.