Noobster24 Posted September 10, 2007 Posted September 10, 2007 (edited) Hi, when you explore your computer with Windows Explorer, you'll notice that almost every file (with a certain filetype) has is icon. Now my problem: I have a $listview, I use a combination of For and _FileListToArray() to ouput the files and directories in a certain directory / on a certain drive. I use GuiCtrlSetImage() to put an image in the listview, but this doesn't show me an image file of that file: GUICtrlSetImage (-1, $location & $filearray[$i]) ;for instance d:\games\myblablafile.php How can I put the icon of every filetype in the listview? (If it's a .doc-file show the M$ Word icon, if it's Adobe Photoshop 2, show that icon etc.) Anyone got an idea? I added a screen to clear things up.. Edited September 10, 2007 by Noobster24 Programs so far:Teh Serializer - Search for licenses for Nero - Windows - Office - Alcohol etc.
Tiger Posted September 10, 2007 Posted September 10, 2007 This is better: GUICtrlSetImage (-1, "D:\games\call of duty 2\cod2_mp.exe", 1) My UDFs:- _RegEnumKey
Noobster24 Posted September 10, 2007 Author Posted September 10, 2007 (edited) This is better: GUICtrlSetImage (-1, "D:\games\call of duty 2\cod2_mp.exe", 1) Hi thanks for the reply, but my explanation sucked. Take a lot at the screenshot in my first post. It shows the icons of certain files (like bmp & exe), but no icons of .cfg or .php etc. (But in Windows Explorer it does..) Something like this: http://www.pocketpcdn.com/articles/systemimages.html but then so than I can use it in Autoit. Edited September 10, 2007 by Noobster24 Programs so far:Teh Serializer - Search for licenses for Nero - Windows - Office - Alcohol etc.
JRSmile Posted October 21, 2007 Posted October 21, 2007 is there any update on that thread, need this functionality too. $a=StringSplit("547275737420796F757220546563686E6F6C75737421","") For $b=1 To UBound($a)+(-1*-1*-1)step(2^4/8);&$b+=1*2/40*µ&Asc(4) Assign("c",Eval("c")&Chr(Dec($a[$b]&$a[$b+1])));''Chr("a")&"HI" Next ;time_U&r34d,ths,U-may=get$the&c.l.u.e;b3st-regards,JRSmile; MsgBox(0x000000,"",Eval("c"));PiEs:d0nt+*b3.s4d.4ft3r.1st-try:-)
DirtDBaK Posted October 21, 2007 Posted October 21, 2007 ha i would like to know how to do this as well i want to implement it into a media player i'm working on.... i know you wonder why/how but i know what my plans r... [center][/center]
MrCreatoR Posted October 21, 2007 Posted October 21, 2007 Hi,Check this example (the functions _FileGetType() and _FileGetIcon isn't mine (sorry, but i can't remember ho's), i just change them a litle):expandcollapse popup#include <GUIConstants.au3> $FileFolderFullPath = @ScriptFullPath GUICreate("Get File/Folder Type & Icon", 300, 150) $GetIcoArr = _FileGetIcon($FileFolderFullPath) GUICtrlCreateButton("", 130, 50, 32, 32, $BS_ICON) GUICtrlSetImage(-1, $GetIcoArr[1], $GetIcoArr[2], 0) GUICtrlCreateLabel(_FileGetType($FileFolderFullPath), 75, 90, 140, 20, $SS_CENTER) GUISetState() While 1 $Msg = GUIGetMsg() If $Msg = -3 Then Exit WEnd Func _FileGetType($FilePathOrExt) Local $Old_Opt_EES = Opt("ExpandEnvStrings", 1) Local $RegDefault, $RegType="", $Ext If _IsFolder($FilePathOrExt) Then $RegDefault = RegRead("HKCR\Folder", "") If $RegDefault <> "" Then $RegType = $RegDefault Else $Ext = StringRegExpReplace($FilePathOrExt, '^.*\.', '.') If $Ext = $FilePathOrExt Then $ExtSaerch = FileFindFirstFile($FilePathOrExt & ".*") $Ext = StringRegExpReplace(FileFindNextFile($ExtSaerch), '^.*\.', '.') $FilePathOrExt &= $Ext EndIf $RegDefault = RegRead("HKCR\" & $Ext, "") If $RegDefault <> "" Then $RegType = RegRead("HKCR\" & $RegDefault, "") If $RegType = "" Then $RegType = $Ext & "-File" EndIf Opt("ExpandEnvStrings", $Old_Opt_EES) Return $RegType EndFunc Func _FileGetIcon($szFile) Local $Old_Opt_EES = Opt("ExpandEnvStrings", 1) Local $szRegDefault = "", $szDefIcon = "", $szExt, $szIconFile, $nIcon=0 Local $RetArr[3] If _IsFolder($szFile) Then $szRegDefault = RegRead("HKCR\Folder", "") If $szRegDefault <> "" Then $szDefIcon = RegRead("HKCR\Folder\DefaultIcon", "") Else $szExt = StringRegExpReplace($szFile, '^.*\.', '.') If $szExt = ".lnk" Then Local $LnkInfoArr = FileGetShortcut($szFile) If Not @error Then Local $RetArr[3] = [2, $LnkInfoArr[4], $LnkInfoArr[5]] Return $RetArr EndIf EndIf If $szExt = $szFile Then $szExt = FileFindFirstFile($szFile & ".*") $szExt = StringRegExpReplace(FileFindNextFile($szExt), '^.*\.', '.') $szFile &= $szExt EndIf $szRegDefault = RegRead("HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\" & $szExt, "ProgID") If $szRegDefault = "" Then $szRegDefault = RegRead("HKCR\" & $szExt, "") If $szRegDefault <> "" Then $szDefIcon = RegRead("HKCR\" & $szRegDefault & "\DefaultIcon", "") EndIf If $szDefIcon = "" Then $szIconFile = "shell32.dll" ElseIf $szDefIcon <> "%1" Then If StringRegExpReplace($szFile, "^.*\\", "") = "shell32.dll" Then $szIconFile = $szFile $nIcon = 0 Else $arSplit = StringSplit($szDefIcon, ",") If IsArray($arSplit) Then $szIconFile = $arSplit[1] If $arSplit[0] > 1 Then $nIcon = $arSplit[2] Else Opt("ExpandEnvStrings", $Old_Opt_EES) Return SetError(1, 0, $RetArr) EndIf EndIf ElseIf $szDefIcon = "%1" Then $szIconFile = $szFile $nIcon = 0 EndIf Opt("ExpandEnvStrings", $Old_Opt_EES) Local $RetArr[3] = [2, $szIconFile, $nIcon] Return $RetArr EndFunc Func _IsFolder($name) Return StringInStr(FileGetAttrib($name), "D") EndFunc Spoiler Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1 AutoIt Russian Community My Work... Spoiler Projects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize ProgramUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF Examples: ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating ) * === My topics === * ================================================== ================================================== AutoIt is simple, subtle, elegant. © AutoIt Team
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