Great job covering your bases... But doesn't this work just as well?
Code:
`::
WinClose, A
return
This is more efficient since there's only three lines to process, and no keystrokes to send. It works for all self-contained windows. I don't have Emacs so I can't test it on that, but I'm reasonably sure it would still work. And, in the direction of efficiency, you can optimize it even further:
Code:
SetBatchLines, -1
SetWinDelay, -1
`::
WinClose, A
return
Of course, this still might not work for some windows, in which case your script would work better. I don't have any such applications to test it on. If this is the case, though, it still should be optimized. There is a gap, albeit an extremely small one, between key press and execution. Here's the optimized version (You can change the values to 0 rather than -1 if it causes an unwanted cpu spike):
Code:
SetBatchLines, -1
SetKeyDelay, -1
`::
SetTitleMatchMode 2
WinGetActiveTitle thiswin
if thiswin contains NetCaptor,Adobe FrameMaker,Mozilla
{
send ^w
return
}
else IfWinActive Emacs ;not emacs, cos emacs uses this key
{
send {ASC 96} ; send self
return
}
else IfWinActive Program Manager ; don't shut down windows
{
; do nothing
}
else
{
send !{F4}
return
}
return
But if it works, the WinClose command would probably be better, not just for efficiency but because it's also more flexible.