Edit August 16:
Requirement: Running instance of Total Commander and I use Alt-F10 to launch it
- (3rd) Modified version of 320MPH script to work with directories only
as alternative for Alt-F10 in Total Commander (works a bit like XCD)
- It CAN use treeinfo.wc (see ini) but also scan drives in one big directory
list (RunList4Folders.txt). All fixed drives can be (re)scanned at once
or separately.
- NOTE: the Scan function replaces treeinfo.wc files, but the result is not
a 100% the same as when done by TC. As far as I can tell it does not seem
to affect TC (Once you create/remove a dir in TC treeinfo.wc will be
'corrected' by TC)
- Control Enter opens folder in new tab
- Shift Enter opens folder in a new tab in the opposite panel
- Creates INI on first run
- Most of the original code is there, commented out... (except for ButtonScan: which has been replaced)
- It no longer searches items with search query anywhere in their path
- Alt-F10 closes App and launches the Total Commander Directory tree
- Scanning creates a new Gui so you can now have it scan in background,
when it is finished it reloads the script.
- Replaced clipboard and ^v method of sending the path with postmessages
and sendinput/play so it should work more accurate now.
I haven't been able to test it very thoroughly so YMMV
Code:
/*
References:
320mph script
http://www.autohotkey.com/forum/topic3010.html
Alternative for Alt-F10/Directory tree
http://www.ghisler.ch/board/viewtopic.php?t=12429
WARNING: CODE IS VERY MESSY, and it rewrites treeinfo.wc if you
use the totcmd method so use at your own risk...
Also scanning (network) drives can take a long time so be patient
___________________________________________
320MPH-Tree
- Modified version of 320MPH script to work with directories only
as alternative for Alt-F10 in Total Commander (works a bit like XCD)
- It CAN use treeinfo.wc (see ini) but also scan drives in one big directory
list (RunList4Folders.txt). All fixed drives can be (re)scanned at once
or separately.
- NOTE: the Scan function replaces treeinfo.wc files, but the result is not
a 100% the same as when done by TC. As far as I can tell it does not seem
to affect TC (Once you create/remove a dir in TC treeinfo.wc will be
'corrected' by TC)
- Control+Enter opens directory in new tab
- Shift+Enter opens directory in a new tab in the opposite panel
- Creates INI on first run
- Most of the original code is there, commented out...
- INI settings:
* UseTreeinfo=1 in INI means use treeinfo.wc, 0 do not use treeinfo.wc
but use RunList4Folders.txt
* UseNetworkDrives=1 in INI means include network drives in search 0 do not include
(you can toggle this via the checkbox as well, it will remember the last choice made)
- Added F2 key to start scanning
Edit August 16:
- Alt-F10 closes App and launches the Total Commander Directory tree
- Scanning creates a new Gui so you can now have it scan in background,
when it is finished it reloads the script.
- Replaced clipboard and ^v method of sending the path with postmessages
and sendinput/play so it should work more accurate now.
TODO:
- Speed up? Search can be a bit slow with many directories
- Make it work with (Microsoft Office) Open/Save dialogs, browse folders, explorer?
___________________________________________
320MPH by Rajat
Ultra Fast Anything-Launcher
Order of Results:
- Recently used items
- Items with name starting with search querry
- Items with search query anywhere in their name
NO LONGER SEARCHES: - Items with search query anywhere in their path
___________________________________________
*/
#SingleInstance ignore
#NoTrayIcon
AutoTrim, Off
SetBatchLines, -1
MainWnd = 320mph-Tree
SetKeyDelay, 0
;___________________________________________
IniFile = %A_ScriptDir%\320mph4folders.ini
; create ini on first run if it does not Exist
IfNotExist, %IniFile%
{
{
ini=
(
[Settings]
UseTreeinfo=1
UseNetworkDrives=0
MaxLastUsed=100
WaitTime=100
ShowIcons=1
MinLen=2
ListFile=RunList4Folders.txt
GuiWMinus=100
GuiHMinus=250
UsedList=
LastUsedList=
)
FileAppend,%ini%,%IniFile%
ini=
}
}
;Reading Settings
;IniRead, PathList, %IniFile%, Settings, PathList, %A_MyDocuments%|%A_ProgramFiles%
;IniRead, TypeList, %IniFile%, Settings, TypeList, exe|lnk|ahk|url|mp3
;IniRead, ExcludeList, %IniFile%, Settings, ExcludeList, about|history|readme|remove|uninstall|license
;IniRead, AlwaysScan, %IniFile%, Settings, AlwaysScan, %UserProfile%\Recent|%A_StartMenuCommon%|%A_StartMenu%|%A_Desktop%
IniRead, UseTreeinfo, %IniFile%, Settings, UseTreeinfo, 0 ; new ini value
IniRead, UseNetworkDrives, %IniFile%, Settings, UseNetworkDrives, 0 ; new ini value
IniRead, MaxLastUsed, %IniFile%, Settings, MaxLastUsed, 50
IniRead, WaitTime, %IniFile%, Settings, WaitTime, 100
IniRead, ShowIcons, %IniFile%, Settings, ShowIcons, 1
IniRead, MinLen, %IniFile%, Settings, MinLen, 2
IniRead, ListFile, %IniFile%, Settings, ListFile, RunList4Folders.txt
IniRead, ShellIntegration, %IniFile%, Settings, ShellIntegration, 1
IniRead, GuiWMinus, %IniFile%, Settings, GuiWMinus, 20
IniRead, GuiHMinus, %IniFile%, Settings, GuiHMinus, 250
IniRead, UsedList, %IniFile%, Settings, UsedList, |
LastUsedList = %UsedList%
GuiW := A_ScreenWidth - GuiWMinus
GuiH := A_ScreenHeight - GuiHMinus
;AlwaysScan := ExpandVars(AlwaysScan)
;PathList := ExpandVars(PathList)
/*
StringRight, ExtChk, A_ScriptFullPath, 4
IfEqual, ExtChk, .exe
IfEqual, ShellIntegration, 1
{
RegWrite, REG_SZ, HKCR, *\Shell\320MPH\Command,, "%A_ScriptFullPath%" "`%1"
RegWrite, REG_SZ, HKCR, Folder\shell\320MPH\command,, "%A_ScriptFullPath%" "`%1"
}
Else
{
RegDelete, HKCR, *\Shell\320MPH,
RegDelete, HKCR, Folder\Shell\320MPH,
}
*/
;RParam = %1%
DriveGet, FixedDrives, List, FIXED ; get fixed drives
DriveGet, NetworkDrives, List, NETWORK ; get mapped network drives
IfEqual, UseNetworkDrives, 1
RParam=%FixedDrives%%NetworkDrives%
Else
RParam=%FixedDrives%
IniRead, UsedList, %IniFile%, Settings, UsedList
IfEqual, UsedList, ERROR
UsedList =
UsedList0 =
Loop, Parse, UsedList, |
{
IfNotExist, %A_LoopField%, Continue
UsedList0 = %UsedList0%|%A_LoopField%
}
UsedList = %UsedList0%
;___________________________________________
;create scanned result list on first run
WhichDrivesToScan=%RParam%
; moved to separate scan routine
Gosub, ReadTree
/*
;scan always updated list
Loop, Parse, AlwaysScan, |
{
Loop, %A_LoopField%\*.*, 0, 1
{
SplitPath, A_LoopFileFullPath, FName, FDir, FExt, FNameNoExt, FDrive
FDir=%FDir%\%FName%
;only filetypes defined are added
;IfNotInString, TypeList, %FExt%, Continue
;excluding items based on ExcludeList
Cont = 0
Loop, Parse, ExcludeList, |
{
IfInString, FName, %A_LoopField%
{
Cont = 1
Break
}
}
IfEqual, Cont, 1
Continue
;reaching here means that file is not to be excluded and
;has a desired extension
RecentList = %RecentList%|%A_LoopFileFullPath%
}
}
*/
StringTrimLeft, RecentList, RecentList, 1
ItemList = %RecentList%%ItemList%
LVGuiW := GuiW - 12
LVGuiH := GuiH - 64
StatusY := GuiH - 25
Gui, -Caption +Border
Gui, Add, Text, x6 y10 w40 h20, Search:
Gui, Add, Edit, x46 y7 w150 h20 vCurrText gGetText,
Gui, Add, Text, x205 y10 w40 h20, Drives:
Gui, Add, Edit, x245 y7 w100 h20 vRParam, %RParam%
Gui, Add, ListView, x6 y35 w%LVGuiW% h%LVGuiH% vSelItem HScroll gSelection AltSubmit, Folder|Full Path
Gui, Add, Button, 0x8000 x445 y7 w50 h20 Default, &Open
Gui, Add, Button, 0x8000 x360 y7 w70 h20, &Scan [F2]
; checkbox for networkdrives
IfEqual, UseNetworkDrives, 1
Gui, Add, Checkbox, checked 0x8000 x560 y12 vCheckNetworkDrives gCheckNetworkDrives, Network Drives
Else
Gui, Add, Checkbox, 0x8000 x600 y12 vCheckNetworkDrives gCheckNetworkDrives, Network Drives
Gui, Add, Text, x6 y%StatusY% w120 h20 vResults,
;Gui, Add, Text, x345 y%StatusY% w200 h20, Directories: %DirCounter%
; display number of directories
Gui, Add, Text, x345 y%StatusY% w150 h20 vDirCounter,
GuiControl,, DirCounter, Dirs: %DirCounter%
; display method (treeinfo.wc or filelist)
If (UseTreeinfo <> 1)
Gui, Add, Text, x205 y%StatusY% w100 h20, Method: Filelist
Else
Gui, Add, Text, x205 y%StatusY% w100 h20, Method: Totcmd
Gui, Font, S10 CDefault Bold, Verdana
Gui, Add, Text, x450 y%StatusY% w150 h20 Right, %MainWnd%
LV_ModifyCol(1, 200)
LV_ModifyCol(2, 250)
;LV_ModifyCol(3, 250)
Gui, Show, h%GuiH% w%GuiW%, %MainWnd%
LastText = fadsfSDFDFasdFdfsadfsadFDSFDf
Gosub, GetText
Control, Choose, 1, SysListView321, %MainWnd%
Return
; Pressing F2 starts scanning process
F2::
Gosub, ButtonScan
Return
!F10::
Gui, Destroy
WinActivate ahk_class TTOTAL_CMD
WinWaitActive ahk_class TTOTAL_CMD
PostMessage 1075, 500,,,ahk_class TTOTAL_CMD ; cm_CDtree=500 Popup directory tree
ExitApp
Return
Up::
IfWinNotActive, %MainWnd%,
{
Send, {Up}
Return
}
ControlGetFocus, CurrCtrl, %MainWnd%
IfEqual, CurrCtrl, Edit1
ControlSend, SysListView321, {Up}, %MainWnd%
Return
Down::
IfWinNotActive, %MainWnd%,
{
Send, {Down}
Return
}
ControlGetFocus, CurrCtrl, %MainWnd%
IfEqual, CurrCtrl, Edit1
ControlSend, SysListView321, {Down}, %MainWnd%
Return
^Del::
IfWinNotActive, %MainWnd%,, Return
ControlGetText, CurrText, Edit1, %MainWnd%
IfNotEqual, CurrText,, Return
SelItem := LV_GetNext()
LV_GetText(FName, SelItem, 1)
LV_GetText(FDir, SelItem, 2)
; LV_GetText(FExt, SelItem, 2)
; LV_GetText(FDir, SelItem, 3)
; IfEqual, FExt,
; Pth = %FDir%\%FName%
; IfNotEqual, FExt,
; Pth = %FDir%\%FName%.%FExt%
; StringReplace, UsedList, UsedList, |%pth%,, A
StringReplace, UsedList, UsedList, |%FDir%,, A
IniWrite, %UsedList%, %IniFile%, Settings, UsedList
LastText = x
Goto, GetText
Return
GetText:
ControlGetText, CurrText, Edit1, %MainWnd%
IfEqual, CurrText, %LastText%, Return
StringLen, Check, CurrText
IfGreater, Check, 0
IfLess, Check, %MinLen%
Return
LastText = %CurrText%
;from last used_____________________________
IfEqual, CurrText,
{
IfEqual, ShowIcons, 1
{
IL_Destroy(ImageListID1)
; Create an ImageList so that the ListView can display some icons:
ImageListID1 := IL_Create(5, 10)
; Attach the ImageLists to the ListView so that it can later display the icons:
LV_SetImageList(ImageListID1)
}
LV_Delete()
Count =
StringTrimLeft, UsedList0, UsedList, 1
Loop, Parse, UsedList0, |
{
;check for change in search querry
ControlGetText, CurrText, Edit1, %MainWnd%
IfNotEqual, CurrText, %LastText%, Goto, GetText
;SplitPath, A_LoopField, FName, FDir, FExt, FNameNoExt
SplitPath, A_LoopField, FName, FDir
FDir=%FDir%\%FName%
Count ++
IfGreater, Count, %MaxLastUsed%, Break
IfEqual, ShowIcons, 1
{
;hIcon := DllCall("Shell32\ExtractAssociatedIconA", UInt, 0, Str, A_LoopField, UShortP, iIndex)
;DllCall("ImageList_ReplaceIcon", UInt, ImageListID1, Int, -1, UInt, hIcon)
;DllCall("DestroyIcon", Uint, hIcon)
IL_Add(ImageListID1, "shell32.dll" , 4) ; assign folder icon
}
; LV_Add("Icon" Count, FNameNoExt, FExt, FDir )
LV_Add("Icon" Count, FName, FDir )
;select first item
IfEqual, A_Index, 1
ControlSend, SysListView321, {Down}, %MainWnd%
}
}
;from all items_____________________________
IfNotEqual, CurrText,
{
IfInString, ItemList, %CurrText%
IfEqual, ShowIcons, 1
{
IL_Destroy(ImageListID1)
; Create an ImageList so that the ListView can display some icons:
ImageListID1 := IL_Create(20, 50)
; Attach the ImageLists to the ListView so that it can later display the icons:
LV_SetImageList(ImageListID1)
}
LV_Delete()
;___________________________________________
; Advanced Search
MatchPList1 =
MatchPList2 =
MatchPList3 =
Count =
;earliest in search results are recently used items
SearchList = %UsedList%%ItemList%
Loop, Parse, SearchList, |
{
;check for change in search querry
ControlGetText, CurrText, Edit1, %MainWnd%
IfNotEqual, CurrText, %LastText%, Goto, GetText
CurrItem = %A_LoopField%
;remove duplicate entry that exists both in usedlist and itemlist
CheckList = %MatchPList1%%MatchPList2%%MatchPList3%|
IfInString, CheckList, |%CurrItem%|, Continue
;SplitPath, CurrItem, FName, FDir, FExt, FNameNoExt, FDrive
SplitPath, CurrItem, FName, FDir
FDir=%FDir%\%FName%
StringLen, Len, CurrText
StringLeft, LText, FName, %Len%
;Matching leftmost text
IfEqual, LText, %CurrText%
{
MatchPList1 = %MatchPList1%|%CurrItem%
Continue
}
;Matching file name only
;fuzzy search
MatchFound = Y
Loop, Parse, CurrText, %A_Space%
IfNotInString, FName, %A_LoopField%
MatchFound = N
IfEqual, MatchFound, Y
{
MatchPList2 = %MatchPList2%|%CurrItem%
Continue
}
/*
;search everywhere
;fuzzy search
MatchFound = Y
Loop, Parse, CurrText, %A_Space%
IfNotInString, CurrItem, %A_LoopField%
MatchFound = N
IfEqual, MatchFound, Y
{
MatchPList3 = %MatchPList3%|%CurrItem%
Continue
}
*/
}
MatchPList = %MatchPList1%%MatchPList2%%MatchPList3%
StringTrimLeft, MatchPList, MatchPList, 1
Loop, Parse, MatchPList, |
{
;check for change in search querry
ControlGetText, CurrText, Edit1, %MainWnd%
IfNotEqual, CurrText, %LastText%, Goto, GetText
Count ++
;SplitPath, A_LoopField, FName, FDir, FExt, FNameNoExt, FDrive
SplitPath, A_LoopField, FName, FDir
FDir=%FDir%\%FName%
IfEqual, ShowIcons, 1
{
; hIcon := DllCall("Shell32\ExtractAssociatedIconA", UInt, 0, Str, A_LoopField, UShortP, iIndex)
; DllCall("ImageList_ReplaceIcon", UInt, ImageListID1, Int, -1, UInt, hIcon)
; DllCall("DestroyIcon", Uint, hIcon)
IL_Add(ImageListID1, "shell32.dll" , 4) ; assign folder icon
}
; LV_Add("Icon" Count, FNameNoExt, FExt, FDir )
LV_Add("Icon" Count, FName, FDir )
;select first item
IfEqual, A_Index, 1
ControlSend, SysListView321, {Down}, %MainWnd%
}
IfEqual, Count,
LV_Delete()
}
;post results
Results := LV_GetCount()
GuiControl,, Results, Results = %Results%
LV_ModifyCol()
Return
; rewrote this routine as it now applies to folders only and you can rescan one or more drives
ButtonScan:
; get drives from control
GuiControlGet, WhichDrivesToScan, , Edit2
; if control is empty return
If (WhichDrivesToScan = "")
{
MsgBox No drives to scan
ControlFocus, Edit1, %MainWnd%
Return
}
; close search gui, disable hotkeys and create new gui
Gui, Destroy
Hotkey, F2, Off
Hotkey, Up, Off
Hotkey, Down, Off
Hotkey, ^Del, Off
Gui, Add, Text, x50 y20 w150 h20 vScanning,
Gui, Show, h60 w200, Scanning...
StringLen, NumberOfDrives, WhichDrivesToScan
StringSplit, ScanDrive, WhichDrivesToScan
DirCount=0
If (UseTreeinfo=1) ; use treeinfo.wc
{
Loop, %NumberOfDrives%
{
xDrive:=ScanDrive%A_Index%
search:="im)^" . xDrive . "\:\\(.*)$"
replace=[$1]
xTemp=
DirCount=0
Loop,%xDrive%:\*.*, 2,1
{
; Read entire directory tree in memory
xTemp=%xTemp%%A_LoopFileFullPath%`r`n
DirCount ++
If DirCount > 99
{
;SplashImage,, W190 H26 B1,, Scanning... %xDrive%:\ --- %A_Index%,
GuiControl,, Scanning, Scanning %xDrive%:\ --- %A_Index%
DirCount=0
}
}
; now remove drive and add [] to make treeinfo.wc
OutputVar2:=RegExReplace(xTemp, search, replace)
Sort, OutputVar2, CLP2
IfExist, %xDrive%:\treeinfo.wc
FileDelete, %xDrive%:\treeinfo.wc
FileAppend, %OutputVar2%, %xDrive%:\treeinfo.wc
FileSetAttrib, +H, %xDrive%:\treeinfo.wc ; set file's "hidden" attribute
xTemp=
DirCount=0
}
OutputVar=
OutputVar2=
ItemList =
WhichDrivesToScan=%RParam%
Gosub, ReadTree
}
Else
Loop, %NumberOfDrives% ; create listfile (e.g. we do not use treeinfo.wc)
{
xDrive:=ScanDrive%A_Index%
xTemp=
; Read entire directory tree in memory
IfExist, %xDrive%:\
{
FileRead, OutputVar, %A_ScriptDir%\%ListFile%
removedrive:="im)^" . xDrive . ".*`r`n"
; before we add the drive to the list, we remove all directories from that drive from the list
OutputVar2:=RegExReplace(OutputVar, removedrive, "")
FileDelete, %A_ScriptDir%\%ListFile%
FileAppend, %OutputVar2%, %A_ScriptDir%\%ListFile%
;SplashImage,, W190 H26 B1,, Scanning... %xDrive%:\
Loop,%xDrive%:\*.*, 2,1
{
xTemp=%xTemp%%A_LoopFileFullPath%`r`n
DirCount ++
If DirCount > 99
{
;SplashImage,, W190 H26 B1,, Scanning... %xDrive%:\ --- %A_Index%,
GuiControl,, Scanning, Scanning %xDrive%:\ --- %A_Index%
DirCount=0
}
}
FileAppend, %XTemp%, %A_ScriptDir%\%ListFile%
xTemp=
DirCount=0
}
Else
{
; SplashImage, Off
MsgBox Drive %xDrive%:\ does not Exist
}
OutputVar=
OutputVar2=
ItemList =
Gosub, ReadTree
}
;SplashImage, Off
ItemList = %RecentList%%ItemList%
LastText =
;ControlFocus, Edit1, %MainWnd%
Gui,Destroy ; close Scanning.... Gui
Reload
Return
ButtonOpen:
Gui, Submit, NoHide
GetKeyState, ShKey, Shift
GetKeyState, CtKey, Control
ControlFocus, SysListView321, %MainWnd%
SelItem := LV_GetNext()
IfEqual, SelItem, 0
RunSearch = 1
/*
IfEqual, CtKey, D
RunSearch = 1
IfEqual, RunSearch, 1
{
RunItem = %CurrText%
;run unrecognised cmd
IfNotExist, %CurrText%
{
FileExist = 0
Goto, AddToList
}
}
*/
;running a found file/folder
IfNotEqual, RunSearch, 1
Loop
{
LV_GetText(FName, SelItem, 1)
; LV_GetText(FExt, SelItem, 2)
LV_GetText(FDir, SelItem, 2)
; LV_GetText(FDir, SelItem, 3)
IfEqual, FExt,
RunItem = %FDir%
IfNotEqual, FExt,
RunItem = %FDir%
IfExist, %RunItem%
{
FileExist = 1
Break
}
}
;remove the last \ from a launched folder's name
;StringRight, check, RunItem, 1
;IfEqual, check, \
; StringTrimRight, RunItem, RunItem, 1
;add the \ back if the target is a drive path
;StringLen, check, RunItem
;IfLess, check, 3
; RunItem = %RunItem%\
Add2History = %RunItem%
;get real file path from shortcut
/*
StringRight, check, RunItem, 4
IfEqual, check, .lnk
{
FileGetShortcut, %RunItem%, LnkTarget
IfNotInString, LnkTarget, {
IfNotInString, LnkTarget, }
RunItem = %LnkTarget%
}
*/
;SplitPath, RunItem, FName, FDir, FExt, FNameNoExt, FDrive
;SplitPath, RunItem, FName, FDir
;FDir=%FDir%\%FName%
/*
;shift key down opens host folder
IfEqual, ShKey, D
{
Run, Explorer %FDir%,, UseErrorLevel
ExitApp
}
*/
AddToList:
;simple run
;IfEqual, RParam,
;Run, %RunItem%, %FDir%, UseErrorLevel
Gui, Destroy
WinActivate ahk_class TTOTAL_CMD
WinWaitActive ahk_class TTOTAL_CMD
IfEqual, CtKey, D, PostMessage 1075, 3001,,,ahk_class TTOTAL_CMD ; cm_opentab - ctrl key down opens directory in new tab
IfEqual, ShKey, D ; - shift key down opens directory in new tab in opposite panel
{
Send {TAB} ; switch panel
PostMessage 1075, 3001,,,ahk_class TTOTAL_CMD ; cm_opentab
}
PostMessage 1075, 2912,,,ahk_class TTOTAL_CMD ; cm_editpath
SendPlay %RunItem%{ENTER} ; sendinput sometimes failed sending ; instead of :
/*
;runtime param
IfNotEqual, RParam,
Run, %RunItem% "%RParam%", %FDir%, UseErrorLevel
*/
IfEqual, FileExist, 1
StringReplace, UsedList, UsedList, |%Add2History%,, A
;leave only max items in list
StringSplit, UsedItem, UsedList, |
UsedList =
Loop, %MaxLastUsed%
{
CurrItem := UsedItem%A_Index%
IfEqual, CurrItem,, Continue
UsedList = %UsedList%|%CurrItem%
}
IniWrite, |%Add2History%%UsedList%, %IniFile%, Settings, UsedList
IniWrite, %LastUsedList%, %IniFile%, Settings, LastUsedList
ExitApp
Selection:
SelItem := LV_GetNext()
LV_GetText(0FName, SelItem, 1)
; LV_GetText(0FExt, SelItem, 2)
LV_GetText(0FDir, SelItem, 2)
; LV_GetText(0FDir, SelItem, 3)
Pth = %0FDir%\%0FName%
; IfEqual, FExt, lnk
; {
; WinGetPos, wX, wY, wW, wH, %MainWnd%
; FileGetShortcut, %Pth%, FTarget
; ToShow = %FTarget%
; ToolTip, %ToShow%, 0, %wH%
; }
; Else
; ToolTip
IfEqual, A_GuiControlEvent, DoubleClick
GoTo, ButtonOpen
Return
GuiEscape:
GuiClose:
ExitApp
; checkbox routine for network drives
CheckNetworkDrives:
GuiControlGet, Status, , Button3
xTemp=
If (NetworkDrives = "")
{
MsgBox No network drives detected...
Return
}
Else
If (Status = 0)
{
StringLen, NumberOfDrives, NetworkDrives
StringSplit, ScanDrive, NetworkDrives
Loop, %NumberOfDrives%
{
xDrive:=ScanDrive%A_Index%
search:="i)" . xDrive
replace=
xTemp:=RegExReplace(WhichDrivesToScan, search, replace)
WhichDrivesToScan=%xTemp%
}
}
Else
WhichDrivesToScan=%WhichDrivesToScan%%NetworkDrives%
xTemp=
IniWrite, %Status%, %IniFile%, Settings, UseNetworkDrives
UseNetworkDrives=%Status%
Gosub, ReadTree
ControlFocus, Edit1, %MainWnd%
Return
; new routine
ReadTree:
If (UseTreeinfo = 1)
{
AllPaths=
; WhichDrivesToScan=%RParam%
StringLen, NumberOfDrives, WhichDrivesToScan
StringSplit, ScanDrive, WhichDrivesToScan
; read entire directory tree in memory, use regexp to add drives and remove []
Loop, %NumberOfDrives%
{
xDrive:=ScanDrive%A_Index%
IfExist, %xDrive%:\treeinfo.wc
{
FileRead, OutputVar, %xDrive%:\treeinfo.wc
search:="im)\[(.*)\]"
adddrive:=xDrive . ":\$1"
OutputVar2:=RegExReplace(OutputVar, search, adddrive)
Sort, OutputVar2, Z
AllPaths=%AllPaths%%OutputVar2%
}
}
ItemList =
DirCounter=0
Loop, Parse, AllPaths, `r`n
{
IfEqual, A_LoopField,, Continue
ItemList = %ItemList%|%A_LoopField%
DirCounter++
}
}
Else { ; eg UseTreeinfo = 0
IfExist, %A_ScriptDir%\%ListFile%
{
ItemList =
DirCounter=
xTemp=
Loop, Read, %A_ScriptDir%\%ListFile%
{
IfEqual, A_LoopReadLine,, Continue
If (UseNetworkDrives = 0)
{
StringLeft, xTemp, A_LoopReadLine, 1
IfNotInString, NetworkDrives, %xTemp%
{
ItemList = %ItemList%|%A_LoopReadLine%
DirCounter++
}
xTemp=
}
Else
{
ItemList = %ItemList%|%A_LoopReadLine%
DirCounter++
}
}
GuiControl,, DirCounter, Dirs: %DirCounter%
}
Else {
InputBox, WhichDrivesToScan, Scan Drives, Which drives to scan (CDEF...), , 200, 120
if ErrorLevel
ExitApp
else
Gosub, ButtonScan
}
}
GuiControl,, DirCounter, Dirs: %DirCounter%
Return
;Chris made this long ago!
ExpandVars(Var)
{
var_new = %var%
in_reference = n
Loop, parse, var_new, `%
{
if in_reference = n
{
in_reference = y
continue
}
; Otherwise, A_LoopField is a variable reference:
StringTrimLeft, ref_contents, %A_LoopField%, 0
StringReplace, var_new, var_new, `%%A_LoopField%`%, %ref_contents%, all
in_reference = n
}
Return, var_new
}