I'm somewhat familiar with Autohotkey but get frustrated quickly when things start to get complex and then subsequently don't work the way I want them to (that's why I thought I should post here
...for instance, in this case simply globally remapping Ctrl-W to Alt-F4 would have some undesired consequences, right? That is, in Firefox, it would close an entire Firefox window (regardless of how many tabs are open) instead of closing the active tab first. In Adobe Photoshop (and in other Adobe programs), it would close the main Adobe window, not the active child window first.
So, what I'm thinking of is something like this (imaginary coding language follows):
Line 1 - Ctrl-W key pressed?; if yes, proceed to line 2; if no, repeat line 1
Line 2 - is active window Firefox? if yes, pass the key press to Firefox; if no, proceed to line 3
Line 3 - is active window an Adobe child
window? if yes, pass the key press to Adobe; if no, proceed to line 4
Line 4 - close active window; proceed to line 1
I don't know if there's a more elegant way of doing it than hard-coding Firefox and Adobe programs into the program, but that's the only way I know of to make Ctrl-W act slightly differently based on which program is active.
The end result should be that Ctrl-W always closes child windows and tabs first, and then the main program window, no matter what program is active. Globally remapping Ctrl-W to Alt-F4 without making exceptions based on which program is active would destroy this subtlety--instead of closing tabs or child windows, Ctrl-W would just close the main program window "by brute force".
Does that make sense? Sorry if you guys already understand the idea; but from your replies I wasn't sure. The part about detecting if the program already uses Ctrl-W for something else would be nice, especially if it could detect if it is used to close child windows, but I don't know if it's absolutely necessary.