MISIIM Posted August 16, 2007 Share Posted August 16, 2007 I have found a few examples but the icon handling has changed. How can I get a valid icon index for an executable? Thanks. Link to comment Share on other sites More sharing options...
weaponx Posted August 16, 2007 Share Posted August 16, 2007 Need more info. How has "icon handling" changed? I don't remember AutoIT having a function to retrieve embedded icons from an exe so you must have been using a dllcall. You need to post some example code. Link to comment Share on other sites More sharing options...
MISIIM Posted August 16, 2007 Author Share Posted August 16, 2007 I'm using GUICtrlSetImage on a ListViewItem. I currently have this. Local $iconCtrl = GUICtrlCreateIcon($file, -259, 0, 0); GUICtrlSetState($iconCtrl, $GUI_HIDE); Local $i; For $i = -259 To 259 If GUICtrlSetImage($iconCtrl, $file, $i) Then GUICtrlDelete($iconCtrl); Return SetExtended($i, $file); EndIf Next GUICtrlDelete($iconCtrl); It doesn't seem to work. Return value is the icon filename and @extended is the icon index. Link to comment Share on other sites More sharing options...
MISIIM Posted August 16, 2007 Author Share Posted August 16, 2007 I hate doing this but I need help. Link to comment Share on other sites More sharing options...
mrbloody369 Posted August 16, 2007 Share Posted August 16, 2007 I hate doing this but I need help.Maybe this will help but I'm new to Autoit so maybe not, but works for me.. Go to your drive the program is located on (example: C:\) click search => Enter "*.ico" in the main search window and click search now. If you see the icon you want to use their just copy and past the .ico to a local folder. Then open you .au3 click compile, click the "..." button by Icon: and walk it out to your .ICO Favorite Quotes"If you apply your mind you can create any thing you can dream of" "Any thing can get done by simply click of a button" Link to comment Share on other sites More sharing options...
Zedna Posted August 16, 2007 Share Posted August 16, 2007 I'm using GUICtrlSetImage on a ListViewItem. I currently have this. Local $iconCtrl = GUICtrlCreateIcon($file, -259, 0, 0); GUICtrlSetState($iconCtrl, $GUI_HIDE); Local $i; For $i = -259 To 259 If GUICtrlSetImage($iconCtrl, $file, $i) Then GUICtrlDelete($iconCtrl); Return SetExtended($i, $file); EndIf Next GUICtrlDelete($iconCtrl); It doesn't seem to work. Return value is the icon filename and @extended is the icon index. Post more code - reproducible. That piece of code make no sense (where is the listview item?) ... Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
MISIIM Posted August 16, 2007 Author Share Posted August 16, 2007 (edited) This assumes that a listview named $listView was already created. expandcollapse popupLocal $time = FileGetTime($pdir & $file); Local $stime = StringFormat("%s-%s-%s %s:%s:%s", $time[0], $time[1], $time[2], $time[3], $time[4], $time[5]); Local $lvItem = GUICtrlCreateListViewItem($file & "|" & Ceiling(FileGetSize($pdir & $file) / 1024) & " KB|" & $stime, $listView); GUICtrlSetImage($lvItem, GetIcon($pdir & $file), @extended, 0); Func GetIcon($file) Local $drive, $path, $filename, $ext; _PathSplit($file, $drive, $path, $filename, $ext); Switch $ext Case ".exe" Local $iconCtrl = GUICtrlCreateIcon($file, -259, 0, 0); GUICtrlSetState($iconCtrl, $GUI_HIDE); Local $i; For $i = -259 To 259 If GUICtrlSetImage($iconCtrl, $file, $i) Then GUICtrlDelete($iconCtrl); Return SetExtended($i, $file); EndIf Next GUICtrlDelete($iconCtrl); Case ".ico" Return SetExtended(-259, $file); Case ".lnk" Local $shortcutInfo = FileGetShortcut($file); Local $iconFileName = $shortcutInfo[4]; Local $iconIndex = $shortcutInfo[5]; Return SetExtended($iconIndex, $iconFileName); EndSwitch Local $ext2 = StringTrimLeft($ext, 1); Local $iconname = IniRead($DATA_DIR & "\assoc.ini", $ext2, "icon", "default.ico"); If $iconname = "default.ico" Or Not FileExists(@ScriptDir & "\icons\" & $iconname) Then Return SetExtended(-259, @ScriptDir & "\default.ico"); EndIf Return SetExtended(-259, @ScriptDir & "\icons\" & $iconname); EndFunc Edited August 16, 2007 by MISIIM Link to comment Share on other sites More sharing options...
Zedna Posted August 16, 2007 Share Posted August 16, 2007 You did bad returning output data from Func expandcollapse popupLocal $icon_file, $icon_index Local $time = FileGetTime($pdir & $file); Local $stime = StringFormat("%s-%s-%s %s:%s:%s", $time[0], $time[1], $time[2], $time[3], $time[4], $time[5]); Local $lvItem = GUICtrlCreateListViewItem($file & "|" & Ceiling(FileGetSize($pdir & $file) / 1024) & " KB|" & $stime, $listView); GetIcon($pdir & $file, $icon_file, $icon_index) GUICtrlSetImage($lvItem, $icon_file, $icon_index, 0); ; ByRef are "output" parametres Func GetIcon($file, ByRef $iconFileName, ByRef $iconIndex ) Local $drive, $path, $filename, $ext; _PathSplit($file, $drive, $path, $filename, $ext); Switch $ext Case ".exe" Local $iconCtrl = GUICtrlCreateIcon($file, -259, 0, 0); GUICtrlSetState($iconCtrl, $GUI_HIDE); Local $i; For $i = -259 To 259 If GUICtrlSetImage($iconCtrl, $file, $i) Then GUICtrlDelete($iconCtrl); $iconFileName = $file $iconIndex = $i Return 1 EndIf Next GUICtrlDelete($iconCtrl); Case ".ico" $iconFileName = $file $iconIndex = -259 Return 1 Case ".lnk" Local $shortcutInfo = FileGetShortcut($file); $iconFileName = $shortcutInfo[4]; $iconIndex = $shortcutInfo[5]; Return 1 EndSwitch Local $ext2 = StringTrimLeft($ext, 1); Local $iconname = IniRead($DATA_DIR & "\assoc.ini", $ext2, "icon", "default.ico"); If $iconname = "default.ico" Or Not FileExists(@ScriptDir & "\icons\" & $iconname) Then $iconFileName = @ScriptDir & "\default.ico" $iconIndex = -259 Return 1 EndIf $iconFileName = @ScriptDir & "\icons\" & $iconname $iconIndex = -259 Return 1 EndFunc Resources UDF ResourcesEx UDF AutoIt Forum Search 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