|
Edd
|
 |
« on: December 31, 2011, 05:24:14 AM » |
|
First of all I select the Z:\ drive.. As you can see inside the Z:\ drive there are 4 Folders more: (A, B, C, J)  Then it will appear this window..  I click the "B" button.. First It will list all Folders inside "Z:\" in a text file:  Then it'll list all Folders inside "Z:\" that begins with "B" (remember I clicked on the "B" button before) In this case:  Then it will show the content inside "Z:\B\"..  After that it'll create an INI document:  As you see the content in the INI document it's exactly the same as the content in treeview. So the problem is.. Inside the Folder "B" there are 3 more Folders:  But the Folder "audio" doesn't starts with "b" so it shouldn't be inside the Folder "B".. What I need it's not to move the Folder "audio" but I need not to appear in the Treeview and in the INI document. Like a loop jump when it founds a Folder not starting with "B" in this case. This is the code of the Script. Formatted for Autohotkey with the GeSHI Syntax Highlighter [ copy or print] SplitPath,Letter ,,,,,Letter ;If user select a full path instead of a drive Letter=%Letter%\ TreeViewWidth := 385 ; Create an ImageList and put some standard system icons into it: Loop 5 ; Below omits the DLL's path so that it works on Windows 9x too: Width=413 tBarHeight=20.5 Title=Selecione el Folder : Gui, 2: +caption +0x400000 ;---------------------------------------------------------- Title Bar & Caption Text ;----------------------------------------------------------- Minimize / Close Icons Cl_IconPos:=395 ; Create a TreeView and a ListView side-by-side to behave like Windows Explorer: Gui, 2: Add, TreeView, vMyTree x15 r20 w %TreeViewWidth% gMyTreeLabel ImageList %ImageListID% SB_SetParts(60, 85) ; Create three parts in the bar (the third part fills all the remaining width). Winset, AlwaysOnTop , OFF , ahk_id %SEWIN_ID% Gui, 2: Show, w415 , Seleccione el Folder : GuiNum=2 { { WinGet, ExStyle , ExStyle , ahk_id %SEWIN_ID% } Fill: { FileAppend, %A_LoopFileName%`n ,%A_Temp%\PhList .txt ,UTF -8 } MsgBox, 4096,,I created a txt document named "PhList.txt", this is the content ... MsgBox, 4096,,That txt document is the content on "%Letter%" { { } If FirstLetterOrNumber =%FilterLetterOrNumber% { ( %Letter%%TempFlderName%`n ),%A_Temp%\PathList.txt,UTF-8 } } { MsgBox, 4096,,I created a txt document named "PathList.txt", this is the content ... } { MsgBox, 4096,,You don't have folders that begins with "%FilterLetterOrNumber%" on "%Letter%". MsgBox, 4096,,Try with other letter ... } { { { } AddSubFoldersToTree(TreeRoot) AddSubFoldersToTree(Folder, ParentItemID = 0) { ; This function adds to the TreeView all subfolders in the specified folder. ; It also calls itself recursively to gather nested folders to any depth. Loop %Folder%\ *.*, 2 ; Retrieve all of Folder's sub-folders. /* Already2=1 If Already2!= { Already2:= TV_GetText(OutputVarName, ParentItemID) StringLeft, OutFirstChar, OutputVarName,1 IfNotInString, OutFirstChar, %FilterLetterOrNumber% { TV_Delete(ParentItemID) } } */ IniWrite, %A_LoopFileFullPath%, %A_Temp%\PathsList .ini , PathsList , %ParentItemID% } } } { MsgBox, 4096,,I created an ini document named "PathsList.ini", this is the content ... } MsgBox, 4096,,The founded root (s ) doesn't contain folders to add... Guishow: Gui, 2: Show,, Seleccione el Folder : MyTreeLabel: ; This subroutine handles user actions (such as clicking). lns=0 Sng:= ItemText=%SelectedItemText% Loop ; Build the full path to the selected folder. { if not ParentID ; No more ancestors. SelectedItemText = %ParentText%\%SelectedItemText% } IniRead, SelectedFullPath , %A_Temp%\PathsList .ini , PathsList , %sel% 2ButtonA: FilterLetterOrNumber=A 2ButtonB: FilterLetterOrNumber=B 2ButtonC: FilterLetterOrNumber=C 2ButtonD: FilterLetterOrNumber=D 2ButtonE: FilterLetterOrNumber=E 2ButtonF: FilterLetterOrNumber=F 2ButtonG: FilterLetterOrNumber=G 2ButtonH: FilterLetterOrNumber=H 2ButtonI: FilterLetterOrNumber=I 2ButtonJ: FilterLetterOrNumber=J 2ButtonK: FilterLetterOrNumber=K 2ButtonL: FilterLetterOrNumber=L 2ButtonM: FilterLetterOrNumber=M 2ButtonN: FilterLetterOrNumber=N 2ButtonO: FilterLetterOrNumber=O 2ButtonP: FilterLetterOrNumber=P 2ButtonQ: FilterLetterOrNumber=Q 2ButtonR: FilterLetterOrNumber=R 2ButtonS: FilterLetterOrNumber=S 2ButtonT: FilterLetterOrNumber=T 2ButtonU: FilterLetterOrNumber=U 2ButtonV: FilterLetterOrNumber=V 2ButtonW: FilterLetterOrNumber=W 2ButtonX: FilterLetterOrNumber=X 2ButtonY: FilterLetterOrNumber=Y 2ButtonZ: FilterLetterOrNumber=Z } Close: { { 2GuiClose: { MsgBox, 4096,Closing ...,Don't worry I've already erased all temp files .,2.5 } } }
Note: To run it and test it you will need to create the folders like an example the ones are in the images.
|
|
|
|
« Last Edit: January 02, 2012, 09:17:31 AM by Edd »
|
Logged
|
|
|
|
|
justice
|
 |
« Reply #1 on: December 31, 2011, 07:31:28 AM » |
|
If I understand you correctly, in order to only add folders beginning with the initial you have clicked you need to add another parameter to the AddSubFoldersToTree function passing the initial, then use that to start the loop:
AddSubFoldersToTree(Folder, ParentItemID = 0, Initial) { ; This function adds to the TreeView all subfolders in the specified folder. ; It also calls itself recursively to gather nested folders to any depth. Loop %Folder%\%Initial%*.*, 2 ; Retrieve all of Folder's sub-folders. { AddSubFoldersToTree(A_LoopFileFullPath, TV_Add(A_LoopFileName, ParentItemID, "Icon4")) TV_Modify(0, "Sort") } If ParentItemID!=0 IniWrite, %A_LoopFileFullPath%, %A_Temp%\PathsList.ini, PathsList, %ParentItemID% }
This is assuming you are recreating the treeview everytime you press the button.
|
|
|
|
|
Logged
|
|
|
|
|
skwire
|
 |
« Reply #2 on: December 31, 2011, 08:21:55 AM » |
|
I simplified a few things where you were duplicating a lot of code when using the whole alphabet. You'll see what I mean. Also, I tried to clean up and indent your code a bit. I'm not a fan of including labels/functions within other labels/functions so, if you would like, I can clean it up much further than this. Here you go: Formatted for Autohotkey with the GeSHI Syntax Highlighter [ copy or print] SplitPath,Letter ,,,,,Letter ;If user select a full path instead of a Drive Letter=%Letter%\ TreeViewWidth := 385 ; Create an ImageList and put some standard system icons into it: Loop 5 ; Below omits the DLL's path so that it works on Windows 9x too: Width=413 tBarHeight=20.5 Title=Selecione el Folder : Gui, 2: +Caption +0x400000 ;---------------------------------------------------------- Title Bar & Caption Text ;----------------------------------------------------------- Minimize / Close Icons Cl_IconPos:=395 { } ; Create a TreeView and a ListView side-by-side to behave like Windows Explorer: Gui, 2: Add, TreeView, vMyTree x15 r20 w %TreeViewWidth% gMyTreeLabel ImageList %ImageListID% SB_SetParts(60, 85) ; Create three parts in the bar (the third part fills all the remaining width). WinSet, AlwaysOnTop , OFF , ahk_id %SEWIN_ID% Gui, 2: Show, w415 , Seleccione el Folder : GuiNum=2 { { WinGet, ExStyle , ExStyle , ahk_id %SEWIN_ID% } Fill: { } { FileAppend, %A_LoopFileName%`n ,%A_Temp%\PhList .txt ,UTF -8 } MsgBox, 4096,,I created a txt document named "PhList.txt", this is the content ... MsgBox, 4096,,That txt document is the content on "%Letter%" { { } If FirstLetterOrNumber =%FilterLetterOrNumber% { ( %Letter%%TempFlderName%`n ),%A_Temp%\PathList.txt,UTF-8 } } { MsgBox, 4096,,I created a txt document named "PathList.txt", this is the content ... } { MsgBox, 4096,,You don't have folders that begins with "%FilterLetterOrNumber%" on "%Letter%". MsgBox, 4096,,Try with other letter ... } { { { } AddSubFoldersToTree(TreeRoot) AddSubFoldersToTree(Folder, ParentItemID = 0) { ; This function adds to the TreeView all subfolders in the specified folder. ; It also calls itself recursively to gather nested folders to any depth. Loop %Folder%\ *.*, 2 ; Retrieve all of Folder's sub-folders. { { } } IniWrite, %A_LoopFileFullPath%, %A_Temp%\PathsList .ini , PathsList , %ParentItemID% } } } { MsgBox, 4096,,I created an ini document named "PathsList.ini", this is the content ... } MsgBox, 4096,,The founded root (s ) doesn't contain folders to add... Guishow: Gui, 2: Show,, Seleccione el Folder : { } MyTreeLabel: ; This subroutine handles user actions (such as clicking). lns=0 Sng:= ItemText=%SelectedItemText% Loop ; Build the full path to the selected folder. { If not ParentID ; No more ancestors. SelectedItemText = %ParentText%\%SelectedItemText% } IniRead, SelectedFullPath , %A_Temp%\PathsList .ini , PathsList , %sel% 2ButtonA: 2ButtonB: 2ButtonC: 2ButtonD: 2ButtonE: 2ButtonF: 2ButtonG: 2ButtonH: 2ButtonI: 2ButtonJ: 2ButtonK: 2ButtonL: 2ButtonM: 2ButtonN: 2ButtonO: 2ButtonP: 2ButtonQ: 2ButtonR: 2ButtonS: 2ButtonT: 2ButtonU: 2ButtonV: 2ButtonW: 2ButtonX: 2ButtonY: 2ButtonZ: } Close: { { 2GuiClose: { MsgBox, 4096,Closing ...,Don't worry I've alReady erased all temp files .,2.5 } } }
|
|
|
|
|
Logged
|
|
|
|
|
|
Edd
|
 |
« Reply #3 on: December 31, 2011, 04:17:21 PM » |
|
I simplified a few things where you were duplicating a lot of code when using the whole alphabet. You'll see what I mean. Also, I tried to clean up and indent your code a bit. I'm not a fan of including labels/functions within other labels/functions so, if you would like, I can clean it up much further than this. Here you go: Formatted for Autohotkey with the GeSHI Syntax Highlighter [ copy or print] SplitPath,Letter ,,,,,Letter ;If user select a full path instead of a Drive Letter=%Letter%\ TreeViewWidth := 385 ; Create an ImageList and put some standard system icons into it: Loop 5 ; Below omits the DLL's path so that it works on Windows 9x too: Width=413 tBarHeight=20.5 Title=Selecione el Folder : Gui, 2: +Caption +0x400000 ;---------------------------------------------------------- Title Bar & Caption Text ;----------------------------------------------------------- Minimize / Close Icons Cl_IconPos:=395 { } ; Create a TreeView and a ListView side-by-side to behave like Windows Explorer: Gui, 2: Add, TreeView, vMyTree x15 r20 w %TreeViewWidth% gMyTreeLabel ImageList %ImageListID% SB_SetParts(60, 85) ; Create three parts in the bar (the third part fills all the remaining width). WinSet, AlwaysOnTop , OFF , ahk_id %SEWIN_ID% Gui, 2: Show, w415 , Seleccione el Folder : GuiNum=2 { { WinGet, ExStyle , ExStyle , ahk_id %SEWIN_ID% } Fill: { } { FileAppend, %A_LoopFileName%`n ,%A_Temp%\PhList .txt ,UTF -8 } MsgBox, 4096,,I created a txt document named "PhList.txt", this is the content ... MsgBox, 4096,,That txt document is the content on "%Letter%" { { } If FirstLetterOrNumber =%FilterLetterOrNumber% { ( %Letter%%TempFlderName%`n ),%A_Temp%\PathList.txt,UTF-8 } } { MsgBox, 4096,,I created a txt document named "PathList.txt", this is the content ... } { MsgBox, 4096,,You don't have folders that begins with "%FilterLetterOrNumber%" on "%Letter%". MsgBox, 4096,,Try with other letter ... } { { { } AddSubFoldersToTree(TreeRoot) AddSubFoldersToTree(Folder, ParentItemID = 0) { ; This function adds to the TreeView all subfolders in the specified folder. ; It also calls itself recursively to gather nested folders to any depth. Loop %Folder%\ *.*, 2 ; Retrieve all of Folder's sub-folders. { { } } IniWrite, %A_LoopFileFullPath%, %A_Temp%\PathsList .ini , PathsList , %ParentItemID% } } } { MsgBox, 4096,,I created an ini document named "PathsList.ini", this is the content ... } MsgBox, 4096,,The founded root (s ) doesn't contain folders to add... Guishow: Gui, 2: Show,, Seleccione el Folder : { } MyTreeLabel: ; This subroutine handles user actions (such as clicking). lns=0 Sng:= ItemText=%SelectedItemText% Loop ; Build the full path to the selected folder. { If not ParentID ; No more ancestors. SelectedItemText = %ParentText%\%SelectedItemText% } IniRead, SelectedFullPath , %A_Temp%\PathsList .ini , PathsList , %sel% 2ButtonA: 2ButtonB: 2ButtonC: 2ButtonD: 2ButtonE: 2ButtonF: 2ButtonG: 2ButtonH: 2ButtonI: 2ButtonJ: 2ButtonK: 2ButtonL: 2ButtonM: 2ButtonN: 2ButtonO: 2ButtonP: 2ButtonQ: 2ButtonR: 2ButtonS: 2ButtonT: 2ButtonU: 2ButtonV: 2ButtonW: 2ButtonX: 2ButtonY: 2ButtonZ: } Close: { { 2GuiClose: { MsgBox, 4096,Closing ...,Don't worry I've alReady erased all temp files .,2.5 } } }
skwire that makes nearly what i need, but stills having problem, I added a "#" button too, but it should show all full path in the treeview and sometimes only appear the first folder but not all the subfolders Also I added the folders structure and the Z: virtual drive to test it. Check it This is the new code: Formatted for Autohotkey with the GeSHI Syntax Highlighter [ copy or print] /* FileSelectFolder, Letter,::{20d04fe0-3aea-1069-a2d8-08002b30309d}, 0,Just Select Your Drive SplitPath,Letter,,,,,Letter ;If user select a full path instead of a Drive Letter=%Letter%\ */ ;Creating virtual drive { VLetter=Z RunWait, %ComSpec% /c subst %VLetter%: C:\ %VLetter%,,hide } Letter=Z:\ TreeViewWidth := 385 ; Create an ImageList and put some standard system icons into it: Loop 5 ; Below omits the DLL's path so that it works on Windows 9x too: Width=413 tBarHeight=20.5 Title=Selecione el Folder : Gui, 2: +Caption +0x400000 ;---------------------------------------------------------- Title Bar & Caption Text ;----------------------------------------------------------- Minimize / Close Icons Cl_IconPos:=395 { } ; Create a TreeView and a ListView side-by-side to behave like Windows Explorer: Gui, 2: Add, TreeView, vMyTree x15 r20 w %TreeViewWidth% gMyTreeLabel ImageList %ImageListID% SB_SetParts(60, 85) ; Create three parts in the bar (the third part fills all the remaining width). WinSet, AlwaysOnTop , OFF , ahk_id %SEWIN_ID% Gui, 2: Show, w415 , Seleccione el Folder : GuiNum=2 { { WinGet, ExStyle , ExStyle , ahk_id %SEWIN_ID% } Fill: { } { FileAppend, %A_LoopFileName%`n ,%A_Temp%\PhList .txt ,UTF -8 } MsgBox, 4096,,I created a txt document named "PhList.txt", this is the content ... MsgBox, 4096,,That txt document is the content on "%Letter%" { { } If FilterLetterOrNumber =# { If FirstLetterOrNumber is digit ;Si la variable esta ocupada de caracteres numericos { ( %Letter%%TempFlderName%`n ),%A_Temp%\PathList.txt,UTF-8 } } { If FirstLetterOrNumber =%FilterLetterOrNumber% { ( %Letter%%TempFlderName%`n ),%A_Temp%\PathList.txt,UTF-8 } } } { MsgBox, 4096,,I created a txt document named "PathList.txt", this is the content ... } { MsgBox, 4096,,You don't have folders that begins with "%FilterLetterOrNumber%" on "%Letter%". MsgBox, 4096,,Try with other letter ... } { { { } AddSubFoldersToTree(TreeRoot) AddSubFoldersToTree(Folder, ParentItemID = 0) { ; This function adds to the TreeView all subfolders in the specified folder. ; It also calls itself recursively to gather nested folders to any depth. Loop %Folder%\ *.*, 2 ; Retrieve all of Folder's sub-folders. { { } } IniWrite, %A_LoopFileFullPath%, %A_Temp%\PathsList .ini , PathsList , %ParentItemID% } } } { MsgBox, 4096,,I created an ini document named "PathsList.ini", this is the content ... } MsgBox, 4096,,The founded root (s ) doesn't contain folders to add... Guishow: Gui, 2: Show,, Seleccione el Folder : { } MyTreeLabel: ; This subroutine handles user actions (such as clicking). lns=0 Sng:= ItemText=%SelectedItemText% Loop ; Build the full path to the selected folder. { If not ParentID ; No more ancestors. SelectedItemText = %ParentText%\%SelectedItemText% } IniRead, SelectedFullPath , %A_Temp%\PathsList .ini , PathsList , %sel% 2Button#: 2ButtonA: 2ButtonB: 2ButtonC: 2ButtonD: 2ButtonE: 2ButtonF: 2ButtonG: 2ButtonH: 2ButtonI: 2ButtonJ: 2ButtonK: 2ButtonL: 2ButtonM: 2ButtonN: 2ButtonO: 2ButtonP: 2ButtonQ: 2ButtonR: 2ButtonS: 2ButtonT: 2ButtonU: 2ButtonV: 2ButtonW: 2ButtonX: 2ButtonY: 2ButtonZ: } Close: { { 2GuiClose: { ;Erasing virual drive { RunWait, %ComSpec% /c subst %VLetter%: /D ,,hide } MsgBox, 4096,Closing ...,Don't worry I've already erased all temp files .,2.5 } } }
|
|
|
|
« Last Edit: January 01, 2012, 06:09:25 PM by Edd »
|
Logged
|
|
|
|
|
kunkel321
|
 |
« Reply #4 on: January 01, 2012, 12:25:50 PM » |
|
Have you guys thought about having a teach-your-self-paced-AHK school/sub-forum? I think there used to be one here a long time ago. I've tried teaching myself off and on over the years, it's pretty hard to wrap your brain around though if you have had no formal instruction. I can make a script that will type out the date... That's about it.
|
|
|
|
|
Logged
|
|
|
|
|
jgpaiva
|
 |
« Reply #5 on: January 02, 2012, 05:39:27 AM » |
|
Have you guys thought about having a teach-your-self-paced-AHK school/sub-forum? I think there used to be one here a long time ago.
I think you're looking for this 
|
|
|
|
|
Logged
|
|
|
|
|