AutoHotkey: Close or minimize windows
(Redirected from Close or minimize windows)
Jump to navigation
Jump to search
This script helps close or minimize different windows with the Esc key. The script needs a config file:
CloseList.txt
Each line contains the method and window name separated by a tab. The methods are:
C Close the window using WinClose
M Minimize the window using WinMinimize
P Minimize the window using PostMessage
The window names can be the title and the string ahk_class followed by the window class name, see the AutoHotkey help, anything else followed by a tab can be used as comment.
For example:
C Filealyzer ahk_class TformMain C Windows Picture and Fax Viewer P ahk_class StrongDC++ StrongDC++ P ahk_class Afx:400000:b:10013:6:580ad1 NetTransport M 8x8 Standard - Table VOG game C ahk_class HH Parent HTML Help
; Esc (Close or minimize some windows) ~Esc:: SetTitleMatchMode 2 ; Make sure that Alt is not pressed (prevents Alt-Tab - Esc problem) if GetKeyState( "Alt" ) Return ; Make sure that LButton is not pressed (prevents Drag - Esc problem) if GetKeyState( "LButton" ) Return loop Read, CloseList.txt { StringSplit aCloseListLine, A_LoopReadLine, %A_Tab% if WinActive( aCloseListLine2 ) { if (aCloseListLine1 = "C") WinClose A if (aCloseListLine1 = "M") WinMinimize A if (aCloseListLine1 = "P") PostMessage 0x112, 0xF020,,, A } } Return
Back to AutoHotkey