AutoHotkey: Close or minimize windows: Difference between revisions

From TotalcmdWiki
Jump to navigation Jump to search
mNo edit summary
(Added category AutoHotkey scripts)
 
(6 intermediate revisions by 3 users not shown)
Line 28: Line 28:
  ~Esc::
  ~Esc::
  SetTitleMatchMode 2
  SetTitleMatchMode 2
 
  ; Make sure that Alt is not pressed (prevents Alt-Tab - Esc problem)
  ; Make sure that Alt is not pressed (prevents Alt-Tab - Esc problem)
  GetKeyState sf_sKeyState, Alt
  if GetKeyState( "Alt" )
IfEqual sf_sKeyState, D, Return
Return
  ; Make sure that LButton is not pressed (prevents Drag - Esc problem)
  ; Make sure that LButton is not pressed (prevents Drag - Esc problem)
  GetKeyState sf_sKeyState, LButton
  if GetKeyState( "LButton" )
IfEqual sf_sKeyState, D, Return
Return
   
   
  loop Read, CloseList.txt
  loop Read, CloseList.txt
Line 48: Line 48:
  PostMessage 0x112, 0xF020,,, A
  PostMessage 0x112, 0xF020,,, A
  }
  }
}
if WinActive( "ahk_class Apollo - Main Window" ) ; Apollo
{
KeyWait Esc
Send {NumpadSub}
; Switch to the next window with Alt-Tab:
Send !{Tab}
  }
  }
   
   
Line 61: Line 53:




<BR>
----
<BR>
Back to [[AutoHotkey]]
Back to [[AutoHotkey]]
[[Category:AutoHotkey scripts|Close or minimize windows]]
[[de:AutoHotkey: Fenster schließen oder Minimieren]]

Latest revision as of 18:39, 6 June 2008

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