Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #SingleInstance Force
- ;previews sound files as you select them in explorer
- oldSelection:=""
- Loop {
- ;first wait till explorer is the active window...
- WinWaitActive, ahk_class CabinetWClass
- ;next we get the explorer window's com object &
- ;find out what is selected...
- hwnd := WinExist("A")
- for window in ComObjCreate("Shell.Application").Windows
- if (window.hwnd==hwnd){
- selected := window.document.SelectedItems
- selString := ""
- for item in selected {
- selString := item.path
- break ;we only care ahout the first file,
- ;there has to be a better way of doing this...
- }
- if( selString != oldSelection) {
- oldSelection:=selString
- ;now we have a new selection, send it to soundplay.
- ;ideally we should check here if it's an audio file,
- ;but soundplay fails silently, so who cares.
- ;also: soundPlay works for most files on my system,
- ;but not all. ex: mp3 & wav play but ogg doesn't
- SoundPlay, %selString%
- }
- }
- lastInput:=A_TimeIdle
- Loop { ;wait for any input that could change the selected file
- Sleep, 25
- if( A_TimeIdle != lastInput)
- break
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement