witelite9
Joined: 02 Oct 2009 Posts: 3 Location: Amarillo, Tx
|
Posted: Wed Nov 04, 2009 5:10 pm Post subject: Search through multiple folders with multiple listviews |
|
|
Hello All,
We needed a simple script that allows 5 different folders on a network to be searched simultaneously. We use this is to track the progress of various files on a network. (From beginning to end of a workflow). We track thousands of faxes, txt, bmp, and Excel files using this. It can be setup for different folder paths. Anyone is free to manipulate or use it.
-it uses 5 different listviews
-it can be refreshed or set to auto-refresh after XX seconds
-the last listview can be set to other folders via a dropdown box
-Double-click opens a file
-Right-Click prints a file
**Currently working on:
-to find a way to limit file types in a listview, (E.g. have the listview only show *.txt, *.bmp, *.tiff...)
-Utilize the checkbox function for opening and printing multiple files.
-embedding the icon.
Feel free to send any comments or suggestions.
| Code: |
;...................................................
;...................:jGGDDDGGj:.....................
;.................jDW#########WGt...................
;...............jD##WGjt;:;tjG###G:.................
;..............G##Dj..........:jK#Wj................
;............:D#Wj.....:::::....:G##j...............
;............D#D:...:;tjjjjjj;.:::j##t..............
;...........G#D:..:jjjttjjjjjGj::::j#K:.............
;..........j#K:..;jjjjGGGGGGGGGf::::G#G.............
;.........:K#j..tjjjGfjjjfGGDDGGj::::#W:............
;.........j#G..:jjfGjjjjfGGDDKKGGj:::G#G............
;.........K#t..jfGGjjjjGGGDKKKKKGf:::t##:...........
;........:#D..:fGGjjjjGGGDKKKKKKDft:::D#j...........
;........j#f..jGGGjjfGGGDKKKKKKKKGj:::G#G...........
;........j#j..jGGfjfGGDDKKKKKKKKKGj:::j#D...........
;........j#j..jGGGGGGDKKKKKDDDDDDGj:::j#K:..........
;........j#t..jGDGGGDKKKKKDDDDDDDf;:::j#K:..........
;........j#j..jGGGGDKKKKDDDDDGGGDj::::G#K:..........
;........j#j:::fGDDKKKKKDDDGGGGGGt:::;G#K...........
;........:#D:::jGDKKKKKDDDGGGffGj::::jG#D...........
;.........W#;:::fGKKKKKDDGGGjjjjt::::fD#G...........
;.........f#G:::tfGKKKKDDGGjjjjj::::jGK#j...........
;.........:W#t:::;jGKKDDDGGjjjt::::jGG#W............
;..........j#K;::::jjGGDGGGjj:::::tfGK#f............
;...........G#D::::::;tjjt;::::::tfGG#W:............
;............K#G;:::::::::::::::jfGG##j.............
;............tW#Gj;:::::::::::j:jfG##K:.............
;.............j##Djjj;::::;jjjj::jK###K:............
;..............jW#WGfjjjjjjffffj;jGK###D............
;...............;G##WDGGffGGGDWKjjjGK###j...........
;.................jD####WW#####KjjjGDW###t..........
;...................;jDKKWKDGD#KjjjjGD###D:.........
;.......................:::..j#WGjjjjGK###G.........
;............................:##DGjjjfDW###t........
;.............................f#WGjjtjGD###K:.......
;..............................K#KGjjjjGGW##f.......
;..............................t##DGjt:::jD#W.......
;...............................j#WGj;:tjjj##.......
;................................D#KG:jjfGG##.......
;................................;##D;jGGGD#K.......
;.................................j##fjGGG##j.......
;..................................D##KDW##G........
;..................................:G#####f.........
;....................................;jjj:..........
;...................................................
;......Multi Folder Search..........................
;.............................by...JJ.&.BB..........
;...................................................
;...................................................
;....With many thanks to the AHK Community!.........
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
;searchDIR_v0.9
#SingleInstance force
SetBatchLines, -1
Start:
Auto = 0
FormatTime, CurrMonth, YYYYMMDDHH24MISS, yyyyMM
;*************************************MULTI FOLDER SEARCH GUI***********************************************************
;Menu, Tray, Icon, %A_workingdir%\Search.ico ;This line changes the green "H" to whatever icon you want
Gui, Add, Text,,Search:
Gui, Add, Edit, x10 y20 BackgroundFFDD99 w200 vA_SearchTerm gSearch
Gui, Add, ListView, y+25 Checked r20 vLV1 ym+40 AltSubmit gMyListView1 Hidden, FOLDER1 ;searchView #1
Gui, Add, ListView, y+25 Checked BackgroundFFDD99 r20 ym+40 vLV1a AltSubmit gMyListView1 xp yp, FOLDER1 ;listView #1
Gui, Add, Listview, Checked r20 vLV2 ym+40 AltSubmit gMyListView2 hidden, FOLDER2 ;searchview #2
Gui, Add, Listview, Checked BackgroundFFDD99 r20 ym+40 vLv2a AltSubmit gMyListView2 xp yp, FOLDER2 ;searchview #2
Gui, Add, ListView, Checked r9 vLV3 ym+40 AltSubmit gMyListView3 Hidden, FOLDER3 ;searchView #3
Gui, Add, ListView, Checked BackgroundFFDD99 r9 ym+40 vLV3a AltSubmit gMyListView3 xp yp, FOLDER3 ;listView #3
Gui, Add, ListView, Checked r9 vLV4 AltSubmit gMyListView4 Hidden, FOLDER4 ;searchView 4
Gui, Add, ListView, Checked BackgroundFFDD99 r9 vLV4a AltSubmit gMyListView4 ym+230 Xm+500, FOLDER4 ;listView 4
Gui, Add, ListView, Checked r20 vLV5 ym+40 AltSubmit gMyListView5 Hidden, FOLDER5 ;searchView #5
Gui, Add, ListView, Checked BackgroundFFDD99 r20 ym+40 vLV5a AltSubmit gMyListView5 xp yp, FOLDER5 ;listView #5
Gui, Add, Button, x220 y5 w60 h40 gButtonReset, Reset Search
Gui, Add, Button, x290 y5 W60 h40 gButtonRefresh, Refresh List(s)
Gui, Add, Button, x360 y5 w120 h40 vAutoRefresh gAutoRefresh, &Auto-Refresh is OFF
;Gui, Add, Text, x760 y18 w300 h20 C808080 , Double Left Click = Open Right Click = Print
;Gui, Add, Radio, x760 y18 w90 h20 +Checked vCurrentMonth , Current Month
Gui, Add, Text, x760 y21 w170 h20 , Other Folders Displayed Below:
Gui, Add, DropDownList, x920 y18 w60 vSelectedMonth gNewMonth, 200911||200910|200909|200908|200907|200906|200905|200904|200903|200902|200901 ;|%DDA%
;*****************PATHWAYS TO THE DIFFERENT FOLDERS*********************************************
searchDIR1=C:\
SearchDir2=C:\Program Files\
SearchDir3=C:\Windows\
SearchDir4=C:\Documents and Settings\
;GuiControlGet, SelectedMonth ;*****DETERMINE WHICH MONTH FOR FOLDER #5*******
SearchDir5=C:\
;***********************************************************************************************
Gui, Listview, SysListview322 ;*********LIST FOLDER CONTENTS FOR FOLDER #1****
Loop, %searchDIR1%\*.*,1
LV_Add("",A_LoopFileName)
LV_ModifyCol()
Gui, Listview, SysListview324 ;*********LIST FOLDER CONTENTS FOR FOLDER #2****
Loop, %searchDIR2%\*.*,1
LV_Add("",A_LoopFileName)
LV_ModifyCol()
Gui, Listview, SysListview326 ;*********LIST FOLDER CONTENTS FOR FOLDER #3****
Loop, %searchDIR3%\*.*,1
LV_Add("",A_LoopFileName)
LV_ModifyCol()
Gui, Listview, SysListview328 ;*********LIST FOLDER CONTENTS FOR FOLDER #4****
Loop, %searchDIR4%\*.*,1
LV_Add("",A_LoopFileName)
LV_ModifyCol()
Gui, Listview, SysListview3210 ;*********LIST FOLDER CONTENTS FOR FOLDER #5****
Loop, %searchDIR5%\*.*,1
LV_Add("",A_LoopFileName)
LV_ModifyCol()
Gui, Show,, Multi Folder Search v0.4
Return
;******************************************** SEARCH ALL FOLDER PATHS *******************************************************
Search: ;Filtering/Search of info typed in Text Box
loop, 5
{
Gui, Submit, NoHide
If (A_SearchTerm) ;This info specific to Listview 1--Note: LV1 & LV1a
{
Count=%A_Index%
Gui, ListView, LV%Count%
LV_Delete()
Gui, ListView, LV%Count%a
Loop,% LV_GetCount()
{
LV_GetText(RetrievedText%Count%, A_Index)
If InStr(RetrievedText%Count%, A_SearchTerm)
{
Gui, ListView, LV%Count%
LV_Add("",RetrievedText%Count%)
Gui, ListView, LV%Count%a
}
}
GuiControl, Hide, LV%Count%a
GuiControl, Show, LV%Count%
Gui, ListView, LV%Count%
}
Else
{
GuiControl, Hide, LV%A_Index%
GuiControl, Show, LV%A_Index%a
Gui, ListView, LV%A_Index%a
}
}
Return
;***************************************** REFRESH BUTTON *****************************************************************
ButtonRefresh:
{
Gui, Listview, SysListview322
LV_Delete() ; delete all rows in the listview
Loop, %searchDIR1%\*.*,1
LV_Add("",A_LoopFileName)
LV_ModifyCol()
Gui, Listview, SysListview324
LV_Delete()
Loop, %searchDIR2%\*.*,1
LV_Add("",A_LoopFileName)
LV_ModifyCol()
Gui, Listview, SysListview326
LV_Delete()
Loop, %searchDIR3%\*.*,1
LV_Add("",A_LoopFileName)
LV_ModifyCol()
Gui, Listview, SysListview328
LV_Delete()
Loop, %searchDIR4%\*.*,1
LV_Add("",A_LoopFileName)
LV_ModifyCol()
Gui, Listview, SysListview3210
LV_Delete()
Loop, %searchDIR5%\*.*,1
LV_Add("",A_LoopFileName)
LV_ModifyCol()
return
}
;***************************************** AUTO REFRESH BUTTON **************************************************************
AutoRefresh:
{
If Not Auto
{
InputBox, Interval, Auto-Refresh, Auto-Refresh is OFF`nInterval in Seconds?,,,,,,,,10
Interval := Interval * 1000
SetTimer, ButtonRefresh, %Interval% ; The Refresh will be called every so many seconds
GuiControl, Text, AutoRefresh, Auto-Refresh is ON
}
Else
{
SetTimer, ButtonRefresh, Off ;THIS LINE CALLS THE 'REFRESH:' SUBROUTINE BELOW---THIS IS WHERE THE ERROR WAS COMING FROM.
GuiControl, Text, AutoRefresh, Auto-Refresh is OFF
}
Auto := Not Auto ; toggles auto-refresh flag
Return
}
;*****************************************LISTVIEW - DOUBLE(OPEN) AND RIGHT(PRINT) CLICKS**************************************
;____________________________________________________________________________________________________________________________
;****************************************************************************************************************************
;*************************************************** LIST VIEW 1
;****************************************************************************************************************************
MyListView1: ;the subroutine fires upon doubleClick of Filename in Listview #1
GuiControlGet, A_SearchTerm
if A_SearchTerm=
{
Gui, Listview, SysListview322
}
Else
{
Gui, Listview, SysListview321
}
if A_GuiEvent = DoubleClick
{
LV_GetText(RowText1, A_EventInfo)
selectedFolder1=%searchDIR1%\%RowText1% ;Selected Folder Pathway for Listview #1
MsgBox, 1, Alert, You have selected %RowText1%. Would you like to open?
IfMsgBox, Cancel
return
IfMsgBox, OK
StringRight, FileExtA, RowText1, 3
if FileExtA in txt
{
run, %selectedFolder1%
Return
}
if FileExtA in bmp,iff,tif,
{
Run, "%selectedFolder1%"
return
}
if FileExtA in xls
{
Run, %SelectedFolder1%
Return
}
else
{
MsgBox, You have selected an invalid file type!
Return
}
return
}
if A_GuiEvent = Rightclick ;Print = RightClick Listview #1
{
LV_GetText(RowText1, A_EventInfo)
selectedFolder1=%searchDIR1%\%RowText1% ;Selected Folder Pathway for Listview #1
StringRight, FileExtB, RowText1, 3
if FileExtB in bmp,iff,tif
{
Run, "%selectedFolder1%" /print
Return
}
if FileExtB in txt
{
run, print %selectedFolder1%,,Hide
Return
}
if FileExtB in xls
{
Run, %SelectedFolder1%
Sleep, 5000
WinWait, Microsoft Excel - %RowText1%
If WinNotActive, Microsoft Excel - RowText1, , WinActivate, Microsoft Excel - RowText1,
WinWaitActive, Microsoft Excel - RowText1,
Send, {CTRLDOWN}t{CTRLUP}
WinWait, Microsoft Excel - RowText1
WinWaitClose
return
}
else
{
MsgBox, You have selected an invalid file type!
Return
}
}
Return
;____________________________________________________________________________________________________________________________
;****************************************************************************************************************************
;*************************************************** LIST VIEW 2
;****************************************************************************************************************************
MyListView2: ;the subroutine fires upon doubleClick of Filename in Listview #2
GuiControlGet, A_SearchTerm
if A_SearchTerm=
{
Gui, Listview, SysListview324
}
Else
{
Gui, Listview, SysListview323
}
if A_GuiEvent = DoubleClick
{
LV_GetText(RowText2, A_EventInfo)
selectedFolder2=%searchDIR2%\%RowText2% ;Selected Folder Pathway for Listview #2
MsgBox, 1, Alert, You have selected %RowText2%. Would you like to open?
IfMsgBox, Cancel
return
IfMsgBox, OK
StringRight, FileExtC, RowText2, 3
if FileExtC in txt
{
run, %selectedFolder2%
Return
}
if FileExtC in bmp,iff,tif,
{
Run, "%selectedFolder2%"
return
}
if FileExtC in xls
{
Run, %SelectedFolder2%
Return
}
else
{
MsgBox, You have selected an invalid file type!
Return
}
return
}
if A_GuiEvent = Rightclick ;Print = RightClick Listview #2
{
LV_GetText(RowText2, A_EventInfo)
selectedFolder2=%searchDIR2%\%RowText2% ;Selected Folder Pathway for Listview #2
StringRight, FileExtB, RowText2, 3
if FileExtB in bmp,iff,tif
{
Run, "%selectedFolder2%" /print
Return
}
if FileExtB in txt
{
run, print %selectedFolder2%,,Hide
Return
}
if FileExtB in xls
{
Run, %SelectedFolder2%
Sleep, 5000
WinWait, Microsoft Excel - %RowText2%
If WinNotActive, Microsoft Excel - RowText2, , WinActivate, Microsoft Excel - RowText2,
WinWaitActive, Microsoft Excel - RowText2,
Send, {CTRLDOWN}t{CTRLUP}
WinWait, Microsoft Excel - RowText2
WinWaitClose
return
}
else
{
MsgBox, You have selected an invalid file type!
Return
}
}
Return
;____________________________________________________________________________________________________________________________
;****************************************************************************************************************************
;*************************************************** LIST VIEW 3
;****************************************************************************************************************************
MyListView3: ;the subroutine fires upon doubleClick of Filename in Listview #3
GuiControlGet, A_SearchTerm
if A_SearchTerm=
{
Gui, Listview, SysListview326
}
Else
{
Gui, Listview, SysListview325
}
if A_GuiEvent = DoubleClick
{
LV_GetText(RowText3, A_EventInfo)
selectedFolder3=%searchDIR3%\%RowText3% ;Selected Folder Pathway for Listview #3
MsgBox, 1, Alert, You have selected %RowText3%. Would you like to open?
IfMsgBox, Cancel
return
IfMsgBox, OK
StringRight, FileExtC, RowText3, 3
if FileExtC in txt
{
run, %selectedFolder3%
Return
}
if FileExtC in bmp,iff,tif,
{
Run, "%selectedFolder3%"
return
}
if FileExtC in xls
{
Run, %SelectedFolder3%
Return
}
else
{
MsgBox, You have selected an invalid file type!
Return
}
return
}
if A_GuiEvent = Rightclick ;Print = RightClick Listview #3
{
LV_GetText(RowText2, A_EventInfo)
selectedFolder3=%searchDIR3%\%RowText3% ;Selected Folder Pathway for Listview #3
StringRight, FileExtB, RowText3, 3
if FileExtB in bmp,iff,tif
{
Run, "%selectedFolder3%" /print
Return
}
if FileExtB in txt
{
run, print %selectedFolder3%,,Hide
Return
}
if FileExtB in xls
{
Run, %SelectedFolder3%
Sleep, 5000
WinWait, Microsoft Excel - %RowText3%
If WinNotActive, Microsoft Excel - RowText3, , WinActivate, Microsoft Excel - RowText3,
WinWaitActive, Microsoft Excel - RowText3,
Send, {CTRLDOWN}t{CTRLUP}
WinWait, Microsoft Excel - RowText3
WinWaitClose
return
}
else
{
MsgBox, You have selected an invalid file type!
Return
}
}
Return
;____________________________________________________________________________________________________________________________
;****************************************************************************************************************************
;*************************************************** LIST VIEW 4
;****************************************************************************************************************************
MyListView4: ;the subroutine fires upon doubleClick of Filename in Listview #4
GuiControlGet, A_SearchTerm
if A_SearchTerm=
{
Gui, Listview, SysListview328
}
Else
{
Gui, Listview, SysListview327
}
if A_GuiEvent = DoubleClick
{
LV_GetText(RowText4, A_EventInfo)
selectedFolder4=%searchDIR4%\%RowText4% ;Selected Folder Pathway for Listview #4
MsgBox, 1, Alert, You have selected %RowText4%. Would you like to open?
IfMsgBox, Cancel
return
IfMsgBox, OK
StringRight, FileExtC, RowText4, 3
if FileExtC in txt
{
run, %selectedFolder4%
Return
}
if FileExtC in bmp,iff,tif,
{
Run, "%selectedFolder4%"
return
}
if FileExtC in xls
{
Run, %SelectedFolder4%
Return
}
else
{
MsgBox, You have selected an invalid file type!
Return
}
return
}
if A_GuiEvent = Rightclick ;Print = RightClick Listview #4
{
LV_GetText(RowText4, A_EventInfo)
selectedFolder4=%searchDIR4%\%RowText4% ;Selected Folder Pathway for Listview #4
StringRight, FileExtB, RowText4, 3
if FileExtB in bmp,iff,tif
{
Run, "%selectedFolder4%" /print
Return
}
if FileExtB in txt
{
run, print %selectedFolder4%,,Hide
Return
}
if FileExtB in xls
{
Run, %SelectedFolder4%
Sleep, 5000
WinWait, Microsoft Excel - %RowText4%
If WinNotActive, Microsoft Excel - RowText4, , WinActivate, Microsoft Excel - RowText4,
WinWaitActive, Microsoft Excel - RowText4,
Send, {CTRLDOWN}t{CTRLUP}
WinWait, Microsoft Excel - RowText4
WinWaitClose
return
}
else
{
MsgBox, You have selected an invalid file type!
Return
}
}
Return
;____________________________________________________________________________________________________________________________
;****************************************************************************************************************************
;*************************************************** LIST VIEW 5
;****************************************************************************************************************************
MyListView5: ;the subroutine fires upon doubleClick of Filename in Listview #5
GuiControlGet, A_SearchTerm
if A_SearchTerm=
{
Gui, Listview, SysListview3210
}
Else
{
Gui, Listview, SysListview329
}
if A_GuiEvent = DoubleClick
{
LV_GetText(RowText5, A_EventInfo)
selectedFolder5=%searchDIR5%\%RowText5% ;Selected Folder Pathway for Listview #5
MsgBox, 1, Alert, You have selected %RowText5%. Would you like to open?
IfMsgBox, Cancel
return
IfMsgBox, OK
StringRight, FileExtC, RowText5, 3
if FileExtC in txt
{
run, %selectedFolder5%
Return
}
if FileExtC in bmp,iff,tif,
{
Run, "%selectedFolder5%"
return
}
if FileExtC in xls
{
Run, %SelectedFolder5%
Return
}
else
{
MsgBox, You have selected an invalid file type!
Return
}
return
}
if A_GuiEvent = Rightclick ;Print = RightClick Listview #5
{
LV_GetText(RowText5, A_EventInfo)
selectedFolder5=%searchDIR5%\%RowText5% ;Selected Folder Pathway for Listview #5
StringRight, FileExtB, RowText2, 3
if FileExtB in bmp,iff,tif
{
Run, "%selectedFolder5%" /print
Return
}
if FileExtB in txt
{
run, print %selectedFolder5%,,Hide
Return
}
if FileExtB in xls
{
Run, %SelectedFolder5%
Sleep, 5000
WinWait, Microsoft Excel - %RowText5%
If WinNotActive, Microsoft Excel - RowText5, , WinActivate, Microsoft Excel - RowText5,
WinWaitActive, Microsoft Excel - RowText5,
Send, {CTRLDOWN}t{CTRLUP}
WinWait, Microsoft Excel - RowText5
WinWaitClose
return
}
else
{
MsgBox, You have selected an invalid file type!
Return
}
}
Return
;*********************************SELECT FOLDER MONTH*********************************************
NewMonth:
;GuiControlGet, SelectedMonth
;if(SelectedMonth=CurrMonth)
; {
; SearchDir5=c:\xxxxxx\xxxxxx\%SelectedMonth%
; }
;Else
; {
; SearchDir5=c:\xxxxxx\xxxxxx\2009\%SelectedMonth%
; }
;Sleep 100
;GoSub ButtonRefresh
Return
;****************************************RESET**************************************************************
ButtonReset:
Gui,Destroy
Gosub Start
Return
;***********************************************************************************************************
GuiClose:
ExitApp
F12::ExitApp
|
|
|