creating an audio seach and play engine

Get help with using AutoHotkey and its commands and hotkeys
sbrady
Posts: 105
Joined: 15 Mar 2014, 20:41
Location: Virginia Beach

creating an audio seach and play engine

22 Feb 2018, 12:19

I found this code to search a folder and display the files in a ListView. I have a need to search folders, which I can code for, but I need to be able to click on the file and play it. can some one help me do this. It may be complicated for a beginner like me.


Code: Select all



; Create the ListView with two columns, Name and Size:
Gui, Add, ListView, r20 w500 gMyListView, Name|Size (KB)

; Gather a list of file names from a folder and put them into the ListView:
Loop, C:\Users\DAW3\Documents\Shortcuts\SB-SFX\Glitch\*.wav     ;A_MyDocuments
    LV_Add("", A_LoopFileName, A_LoopFileSizeKB)

LV_ModifyCol()  ; Auto-size each column to fit its contents.
LV_ModifyCol(2, "Integer")  ; For sorting purposes, indicate that column 2 is an integer.

; Display the window and return. The script will be notified whenever the user double clicks a row.
Gui, Show
return

MyListView:
if A_GuiEvent = DoubleClick
{
    LV_GetText(RowText, A_EventInfo)  ; Get the text from the row's first field.
    ToolTip You double-clicked row number %A_EventInfo%. Text: "%RowText%"
}
return

GuiClose:  ; Indicate that the script should exit automatically when the window is closed.
ExitApp
garry
Posts: 1569
Joined: 22 Dec 2013, 12:50

Re: creating an audio seach and play engine

23 Feb 2018, 04:33

example
show ' MP3 / wav / wma ' at A_Desktop or A_Mydocuments and can search by FileName
EDIT : added Fileselectfolder and other modifications

Code: Select all

;https://autohotkey.com/boards/viewtopic.php?f=5&t=44619

;modified = 20180223/2
;created  = 20180223

ext1:="mp3,wma,wav,m4a"     ;- search files with these extensions in %a_mydocuments%  and %a_desktop%

#warn
#NoEnv
SetWorkingDir, %A_ScriptDir%
SendMode,Input
SetBatchLines, -1
Filename1=LV_MusicRead

Gui,2:default
Gui,2:Font,s12, Lucida Console
Gui,2:Color,Black
Gui,2:Color,ControlColor, Black

Gui,2: Add, ListView,grid backgroundGray cBlack x10 y10 h800 w740 gMyLV1 vLV1 +altsubmit, Name|Fullpath
LV_ModifyCol(1, 700),LV_ModifyCol(2,0)

Gui,2:add,Text  ,x10   y835     w100  cWhite   ,Search-Word=
Gui,2:Font,cDefault,FixedSys
Gui,2:add,Edit  ,x140  y830 h27 w130 vSearchx gSearchx cGray,
Gui,2:add,button,x280  y830 h27 w100 vFolder1 gFolder1,Desktop
Gui,2:add,button,x390  y830 h27 w100 vFolder2 gFolder2,MyDoc
Gui,2:add,button,x500  y830 h27 w120 vFolderX gFolderX,FolderSelect

Gui,2:add,Edit  ,x640  y830 h27 w100 vTotal   cYellow right
Gui,2:show,x10 y10 h870 w780,%filename1%
gosub,folder1
Guicontrol,2:Focus,searchx
return
;-------------------------------------------------

2Guiclose:
exitapp
;--------------------------

FolderX:
PRESELECT  = ::{20d04fe0-3aea-1069-a2d8-08002b30309d}         ;- search from here
FileSelectFolder,MF,%PRESELECT%
if MF=
  return

if (MF="C:\")
  xx1:="C:"
goto,fillx
return

folder1:
xx1=%a_desktop%
goto,fillx
return

folder2:
xx1=%a_mydocuments%
goto,fillx
return
;-------------------------------------------------

fillx:
i=0
Gui,2:ListView, LV1
SplitPath,xx1, name2, dir2, ext2, name_no_ext2, drive2
if (xx1="C:")
   name2=C_Drive
LV_Delete()
;GuiControl,2: -Redraw,LV1
loop,%xx1%\*.*,0,1
{
 x:= a_loopfilefullpath
 SplitPath,x, name, dir, ext, name_no_ext, drive
  if ext=
   continue
 else
   {
   if ext in %ext1%
     {
     i++
     n:= a_loopfilename
       LV_Add("",n,x)
     GuiControl,2:,Total,%i%
     }
   }
}
;GuiControl,2: +Redraw,LV1
GuiControl,2:,Total,END=%i%
Guicontrol,2:Focus,searchx
;- maybe save once as textfile for faster reading instead search whole drive
ControlGet,Text2, List, , SysListView321,%filename1%
ifexist,%name2%.txt
  filedelete,%name2%.txt
Fileappend,%text2%,%name2%.txt
return
;-------------------------------------------------

MyLV1:
Gui,2:ListView, LV1
if A_GuiEvent = Normal
  {
  LV_GetText(C2,A_EventInfo,2)
  run,%c2%
  }

if A_GuiEvent = Rightclick
  {
  LV_GetText(C2,A_EventInfo,2)
  msgbox, 262208,FullPath ,%c2%
  }
return
;-------------------------------------------------
searchx:
Gui,2:submit,nohide
Gui,2:ListView, LV1
if searchx=
   {
   gosub,filltext
   return
   }
ControlGet,Text1, List, , SysListView321,%filename1%    ;- read Listview text
LV_Delete()
GuiControl,2:,Total,
i=0
loop,parse,text1,`n
{
stringsplit,c,a_loopfield,`t                ;- split by TAB
if c1 contains %searchx%
  {
  i++
  LV_Add("",c1,c2)
  GuiControl,2:,Total,%i%
  }
}
return
;---------------------------------------------------

filltext:
LV_Delete()
i=0
Loop,parse,text2,`n,`r
{
stringsplit,c,a_loopfield,`t                ;- split by TAB
  {
  i++
  LV_Add("",c1,c2)
  }
}
GuiControl,2:,Total,%i%
return
;============ END SCRIPT =====================================

Return to “Ask For Help”

Who is online

Users browsing this forum: Bing [Bot], HigherA, Pepineros and 100 guests