[AHK V2] Closing lister instances with opened audio files

Discuss and announce Total Commander plugins, addons and other useful tools here, both their usage and their development.

Moderators: Hacker, petermad, Stefan2, white

Post Reply
User avatar
Stiltzkin
Member
Member
Posts: 194
Joined: 2004-09-10, 17:15 UTC

[AHK V2] Closing lister instances with opened audio files

Post by *Stiltzkin »

what?
the script closes all lister windows with the specified file extensions in the title.

why?
this may be a little specific, but it is useful if you use lister to preview/quick listen audio files and would otherwise have multiple active lister windows playing sound (or you'd have to close the active one each time).

how?
- requires ahk v2
- default hotkey is shift+F3. but can easily be changed to another hotkey involving F3

Code: Select all

~+F3:: {
    audioExtensions := [".mp3", ".wav", ".ogg", ".m4a"]

    hwndList := WinGetList("ahk_class TLister")
    for hwnd in hwndList {
		title := WinGetTitle(hwnd)

   for ext in audioExtensions {
		if InStr(title, ext) {
			OutputDebug "[AHK][TOTALCMD] Closing Lister window: [" title "], HWND: [" hwnd "]."
			WinClose(hwnd)
			break
            }
		}
	}
}
Post Reply