myspacee Posted May 11, 2010 Share Posted May 11, 2010 Hello to all, modify this help script to list all directory in drive c:\ : #include <GUIComboBox.au3> #include <GuiConstantsEx.au3> #include <Constants.au3> #include <WindowsConstants.au3> Opt('MustDeclareVars', 1) $Debug_CB = False ; Check ClassName being passed to ComboBox/ComboBoxEx functions, set to True and use a handle to another control to see it work _Main() Func _Main() Local $hCombo ; Create GUI GUICreate("ComboBox Add Dir", 400, 296) $hCombo = GUICtrlCreateCombo("", 2, 2, 396, 296, BitOR($CBS_SIMPLE,$CBS_AUTOHSCROLL,$CBS_DISABLENOSCROLL,$WS_VSCROLL)) GUISetState() ; Add files _GUICtrlComboBox_BeginUpdate($hCombo) _GUICtrlComboBox_AddDir($hCombo, "c:\*.", $DDL_DIRECTORY, False) _GUICtrlComboBox_EndUpdate($hCombo) ; Loop until user exits Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() EndFunc ;==>_Main help explains that : _GUICtrlComboBox_AddDir($hWnd, $sFile[, $iAttributes = 0[, $fBrackets = True]]) $fBrackets flag include/exclude brackets when $DDL_DRIVES is used but has no effect on posted script. Anyone can correct it for me ? Thank you dor any info, m. Link to comment Share on other sites More sharing options...
GEOSoft Posted May 11, 2010 Share Posted May 11, 2010 And it does precisly what it says it does. $fBrackets flag include/exclude brackets when $DDL_DRIVES is used. You're not using $DDL_DRIVES, you're using $DDL_DIRECTORY and it has no effect there. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
myspacee Posted May 11, 2010 Author Share Posted May 11, 2010 thank you Geosoft for reply, fomule again request. How list all c:\ directories without brackets with above script ? (if is possible) Thank you, m. Link to comment Share on other sites More sharing options...
GEOSoft Posted May 11, 2010 Share Posted May 11, 2010 (edited) I modified one of my standard functions to get the folders. expandcollapse popup#include <GuiConstantsEx.au3> #include <ComboConstants.au3> #include <Constants.au3> #include <WindowsConstants.au3> #include <array.au3> Opt('MustDeclareVars', 1) ;$Debug_CB = False ; Check ClassName being passed to ComboBox/ComboBoxEx functions, set to True and use a handle to another control to see it work _Main() Func _Main() Local $hCombo ; Create GUI GUICreate("ComboBox Add Dir", 400, 296) $hCombo = GUICtrlCreateCombo("", 2, 2, 396, 296, BitOR($CBS_SIMPLE,$CBS_AUTOHSCROLL,$CBS_DISABLENOSCROLL,$WS_VSCROLL)) ;GUISetState() ; Add Folders Local $aFolders = _Fldr_ListToArray("c:", "", False) GUICtrlSetData($hCombo, _ArrayToString($aFolders)) GUISetState() ; Loop until user exits Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() EndFunc ;==>_Main ;=============================================================================== ; Function Name: _Fldr_ListToArray() ; Description: Recursivly find the folders in a given path (returns full path for each) ; Syntax: _Fldr_ListToArray($s_Path[, $b_Recurse[, $b_Hidden[, $b_System]]]) ; Parameter(s): $s_Path - The base folder ; $s_Ignore - Pipe (|) separated list of folders to ignore. The * wildcard is accepted. ; $b_Recurse - If True (default) search is recursive ; $b_Hidden - If False (default) "Hidden" folders are NOT included ; $b_System If True (default) "System" folders are included. ; Requirements: ; Return Value(s): Success - A 0 based array of the folders with paths ; Failure - Sets @Error to 1 ; Author(s): George (GEOSoft) Gedye ; Notes: ;Example(s): #cs ;; folders in C:\, non-recursive Excluding the Windows folder and including Hidden and System folders $aArray = _Fldr_ListToArray("c:", "Windows", True) _ArrayDisplay($aArray) #ce ;=============================================================================== Func _Fldr_ListToArray($s_Path, $s_Ignore = "", $b_Recurse = True, $b_Hidden = False, $b_System = True) If StringRight($s_Path, 1) <> "\" Then $s_Path &= "\" $s_Path = '"' & $s_Path & '"' Local $s_Working = @WorkingDir, $s_Env = "", $hPID, $aIgnore, $a_Fldrs FileChangeDir(@TempDir) Local $sFile = "dir.txt" If FileExists($sFile) Then FileDelete($sFile) If $b_Recurse Then $s_Env &= " /s" $s_Env &= " /b /o:n" Local $s_Attrib = " /a:d" If NOT $b_Hidden Then $s_Attrib &= "-h" If NOT $b_System Then $s_Attrib &= "-s" $s_Env &= $s_Attrib EnvSet("DIRCMD", $s_Env) $hPID = Run(@ComSpec & ' /c dir ' & $s_Path & " > " & $sFile , "", @SW_HIDE, 0x02) While ProcessExists($hPID) If @error Then ExitLoop WEnd Local $s_Str = StringStripWS(FileRead($sFile), 2) FileDelete($sFile) EnvSet("DIRCMD", "") FileChangeDir($s_Working) If $s_Str Then If $s_Ignore Then $aIgnore = StringSplit($s_Ignore, "|", 2) For $i = 0 To UBound($aIgnore) -1 $aIgnore[$i] = StringRegExpReplace($aIgnore[$i], "\.*\*+", "\.\*\?") $s_Str = StringRegExpReplace($s_Str, "(?i)(?m:^).+\\" & $aIgnore[$i] & "\\.*(?:\z|\v)+", "") Next EndIf $a_Fldrs = StringRegExp($s_Str, "(?i)(?m:^)(.+)(?:\v|$)+", 3) If Not @error Then #cs For $i = 0 To UBound($a_Fldrs) -1 $a_Fldrs[$i] &= "\" Next #ce Return $a_Fldrs EndIf EndIf Return SetError(1) EndFunc ;;<===>_Fldr_ListToArray Edit: Moved GUISetState() to where it makes more sense. Edited May 11, 2010 by GEOSoft George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
myspacee Posted May 11, 2010 Author Share Posted May 11, 2010 Thank you! m. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now