c.haslam Posted August 9, 2018 Share Posted August 9, 2018 (edited) I am adding to Melba23's ChooseFileFolder.au3 to have similar appearance and capabilities to FileSelectFolder(), including connecting drives and mapped drives. Where can I find the icons that appear in FileSelectFolder? Or are the icons picked up based on file-extension associations, as PhoenixXL did here ? Edited August 10, 2018 by c.haslam Spoiler CDebug Dumps values of variables including arrays and DLL structs, to a GUI, to the Console, and to the Clipboard Link to comment Share on other sites More sharing options...
AutoBert Posted August 9, 2018 Share Posted August 9, 2018 (edited) I don't know from where the @AutoIt-Team (@Jos etc) these icon fetches. For a own project i use functions from @progandy. Here a demo script: expandcollapse popup; *** Start added by AutoIt3Wrapper *** #include <WindowsConstants.au3> ; *** End added by AutoIt3Wrapper *** #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Add_Constants=n #AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <APIShellExConstants.au3> #include <FileConstants.au3> #include <MsgBoxConstants.au3> #include <GUIConstantsEx.au3> #include <GuiTreeView.au3> #include <GuiListView.au3> #include <File.au3> Global Const $tagSHFILEINFO = 'ptr hIcon; int iIcon; DWORD dwAttributes; CHAR szDisplayName[255]; CHAR szTypeName[80];' Global $FOLDER_ICON_INDEX = _GUIImageList_GetFileIconIndex(@SystemDir, True, 1) ;Global $UP_ICON_INDEX = _GUIImageList_GetFileIconIndex($sIconDir & 'up.ico', True, 1) Global $idTV, $idRoot, $hIcon Global $aDirs, $aFiles ; Create GUI Global $hGui = GUICreate("Demo _GUICtrlTreeView_AddChild", 500, 700, 0, 0, $WS_SIZEBOX) GUISetFont(14) $idTV = GUICtrlCreateTreeView(2, 2, 494, 594) GUICtrlSetResizing(-1, $GUI_DOCKTOP) ;$hTV = ControlGetHandle($hGui, '', $idTV) ;use $hTV if needed, the controlid is not accepted _GUICtrlTreeView_SetNormalImageList($idTV, _GUIImageList_GetSystemImageList(True)) GUISetState(@SW_SHOW) Global $sAutoItPath = StringReplace(StringReplace(@AutoItExe, '_x64', ''), 'autoit3.exe', '') ;ConsoleWrite($sAutoItPath&@CRLF) If Not FileExists($sAutoItPath & 'autoit3.exe') Then $sAutoItPath = '' If MsgBox($MB_YESNO, 'Ordner nicht gefunden', 'Möchten Sie selbst danach suchen?', 0, $hGui) = 6 Then $sAutoItPath = FileSelectFolder('AutoIt Ordner manuell suchen', 'c:\') EndIf If $sAutoItPath = '' Then Exit EndIf $idRoot = _GUICtrlTreeView_Add($idTV, 0, $sAutoItPath, $FOLDER_ICON_INDEX) $aDirs = _FileListToArray($sAutoItPath, '*', 2) If Not @error Then For $i = 1 To $aDirs[0] ; Add items _GUICtrlTreeView_AddChild($idTV, $idRoot, $aDirs[$i], $FOLDER_ICON_INDEX, $FOLDER_ICON_INDEX) Next EndIf $aFiles = _FileListToArray($sAutoItPath, '*', 1) If Not @error Then For $i = 1 To $aFiles[0] ; Add items $hIcon = _GUIImageList_GetFileIconIndex($aFiles[$i], True) _GUICtrlTreeView_AddChild($idTV, $idRoot, $aFiles[$i], $hIcon);,$hIcon) Next EndIf _GUICtrlTreeView_Expand($idTV) ; Loop until the user exits. Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() ; Author: progandy (www.autoit.de) Func _GUIImageList_GetSystemImageList($bLargeIcons = False) Local $dwFlags, $hIml, $FileInfo = DllStructCreate($tagSHFILEINFO) $dwFlags = BitOR($SHGFI_USEFILEATTRIBUTES, $SHGFI_SYSICONINDEX) If Not ($bLargeIcons) Then $dwFlags = BitOR($dwFlags, $SHGFI_SMALLICON) EndIf ;~ '// Load the image list - use an arbitrary file extension for the ;~ '// call to SHGetFileInfo (we don't want to touch the disk, so use ;~ '// FILE_ATTRIBUTE_NORMAL && SHGFI_USEFILEATTRIBUTES). $hIml = _WinAPI_SHGetFileInfo(".txt", $FILE_ATTRIBUTE_NORMAL, _ DllStructGetPtr($FileInfo), DllStructGetSize($FileInfo), $dwFlags) Return $hIml EndFunc ;==>_GUIImageList_GetSystemImageList ; Author: progandy (www.autoit.de) Func _WinAPI_SHGetFileInfo($pszPath, $dwFileAttributes, $psfi, $cbFileInfo, $uFlags) Local $return = DllCall("shell32.dll", "dword_ptr", "SHGetFileInfo", "str", $pszPath, "DWORD", $dwFileAttributes, "ptr", $psfi, "UINT", $cbFileInfo, "UINT", $uFlags) If @error Then Return SetError(@error, 0, 0) Return $return[0] EndFunc ;==>_WinAPI_SHGetFileInfo ; Author: progandy (www.autoit.de) Func _GUIImageList_GetFileIconIndex($sFileSpec, $bLargeIcons = False, $bForceLoadFromDisk = False) Local $dwFlags, $FileInfo = DllStructCreate($tagSHFILEINFO) $dwFlags = $SHGFI_SYSICONINDEX If $bLargeIcons Then $dwFlags = BitOR($dwFlags, $SHGFI_LARGEICON) Else $dwFlags = BitOR($dwFlags, $SHGFI_SMALLICON) EndIf ;~ ' We choose whether to access the disk or not. If you don't ;~ ' hit the disk, you may get the wrong icon if the icon is ;~ ' not cached. But the speed is very good! If Not $bForceLoadFromDisk Then $dwFlags = BitOR($dwFlags, $SHGFI_USEFILEATTRIBUTES) ;~ ' sFileSpec can be any file. You can specify a ;~ ' file that does not exist and still get the ;~ ' icon, for example sFileSpec = "C:\PANTS.DOC" Local $lR = _WinAPI_SHGetFileInfo( _ $sFileSpec, $FILE_ATTRIBUTE_NORMAL, DllStructGetPtr($FileInfo), DllStructGetSize($FileInfo), _ $dwFlags _ ) If ($lR = 0) Then Return SetError(1, 0, -1) Else Return DllStructGetData($FileInfo, "iIcon") EndIf EndFunc ;==>_GUIImageList_GetFileIconIndex Edited August 9, 2018 by AutoBert Link to comment Share on other sites More sharing options...
c.haslam Posted August 9, 2018 Author Share Posted August 9, 2018 Thanks. How would I modify your script to make F:\ the root rather than the Autoit folder? Spoiler CDebug Dumps values of variables including arrays and DLL structs, to a GUI, to the Console, and to the Clipboard Link to comment Share on other sites More sharing options...
AutoBert Posted August 9, 2018 Share Posted August 9, 2018 Just replacing this block: Global $sAutoItPath = StringReplace(StringReplace(@AutoItExe, '_x64', ''), 'autoit3.exe', '') If Not FileExists($sAutoItPath & 'autoit3.exe') Then $sAutoItPath = '' If MsgBox($MB_YESNO, 'Ordner nicht gefunden', 'Möchten Sie selbst danach suchen?', 0, $hGui) = 6 Then $sAutoItPath = FileSelectFolder('AutoIt Ordner manuell suchen', 'c:\') EndIf If $sAutoItPath = '' Then Exit EndIf with Global $sAutoItPath = "F:\" can you post a screenshot, i am interested to see result but only a single computer isle. Link to comment Share on other sites More sharing options...
c.haslam Posted August 10, 2018 Author Share Posted August 10, 2018 (edited) Here's the change: Global $sAutoItPath = 'F:\' ;~ Global $sAutoItPath = StringReplace(StringReplace(@AutoItExe, '_x64', ''), 'autoit3.exe', '') ;~ ;ConsoleWrite($sAutoItPath&@CRLF) ;~ If Not FileExists($sAutoItPath & 'autoit3.exe') Then ;~ $sAutoItPath = '' ;~ If MsgBox($MB_YESNO, 'Ordner nicht gefunden', 'Möchten Sie selbst danach suchen?', 0, $hGui) = 6 Then ;~ $sAutoItPath = FileSelectFolder('AutoIt Ordner manuell suchen', 'c:\') ;~ EndIf ;~ If $sAutoItPath = '' Then Exit ;~ EndIf and here's the screenshot: I was expecting a disk drive image. I tried Global $sAutoItPath = 'F:' with $aDirs = _FileListToArray($sAutoItPath&'\', '*', 2) but the icon for F: wa still a folder. Edited August 10, 2018 by c.haslam Spoiler CDebug Dumps values of variables including arrays and DLL structs, to a GUI, to the Console, and to the Clipboard Link to comment Share on other sites More sharing options...
c.haslam Posted August 10, 2018 Author Share Posted August 10, 2018 (edited) I got it to work properly. I added Global $Drive_ICON_INDEX = _GUIImageList_GetFileIconIndex('F:',True,1) and changed the $idRoot line to $idRoot = _GUICtrlTreeView_Add($idTV, 0, $sAutoItPath, $DRIVE_ICON_INDEX) The GUI was then Thank you! One fewer alligator in my swamp! Edited August 10, 2018 by c.haslam Spoiler CDebug Dumps values of variables including arrays and DLL structs, to a GUI, to the Console, and to the Clipboard 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