corgano Posted June 18, 2009 Share Posted June 18, 2009 What I need to do is, after you select the file, make an icon controll. I need it to be the icon of the selected file, or the program that opens the select file. What is the best way to do this? GUICreate("123",100,100) $file = FileOpenDialog("select file","","all files (*.*)") GUICtrlCreateIcon() while 1 sleep(100) wend 0x616e2069646561206973206c696b652061206d616e20776974686f7574206120626f64792c20746f206669676874206f6e6520697320746f206e657665722077696e2e2e2e2e Link to comment Share on other sites More sharing options...
BrettF Posted June 18, 2009 Share Posted June 18, 2009 Rough example of one way to do it. I seem to remember another way though... expandcollapse popup#include <GUIConstantsEx.au3> ;Create GUI GUICreate(" My GUI Icons", 250, 250) ;Get File $file = FileOpenDialog("", "", "All Files (*.*)") ;Find Ext $Ext = StringRegExpReplace($file, "^.*\.", ".$1") ;Read the icon place $iconplace = RegRead("HKCR\" & $Ext, "") ;Test if icon place exists If $iconplace Then ;Get icon string format is PATH,ORD $icon = RegRead("HKCR\" & $iconplace & "\DefaultIcon", "") Else ;Get icon string format is PATH,ORD $icon = RegRead("HKCR\" & $Ext & "\DefaultIcon", "") EndIf MsgBox (0, "", $icon) ;Split string $split = StringSplit($icon, ",") ;Icon path, replace " $icon_file = StringReplace ($split[1], '"', '') ;If string contains %SYSTEMROOT% Then we must tell AutoIt to handle it. If StringInStr ($icon_file, "%") Then ;Save the value so we can set it back $old_ExpandEnvStrings = Opt ("ExpandEnvStrings", 1) EndIf ;Icon $icon_ord = $split[2] ;Set Icon $icon = GUICtrlCreateIcon($icon_file, 0 - $icon_ord, 20, 20) ;Set it back Opt ("ExpandEnvStrings", $old_ExpandEnvStrings) ;Show GUI GUISetState() ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then Exit WEnd Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
Inverted Posted June 18, 2009 Share Posted June 18, 2009 That script just gives me a msgbox saying : %1 !? Link to comment Share on other sites More sharing options...
GEOSoft Posted June 18, 2009 Share Posted June 18, 2009 Rough example of one way to do it. I seem to remember another way though... expandcollapse popup#include <GUIConstantsEx.au3> ;Create GUI GUICreate(" My GUI Icons", 250, 250) ;Get File $file = FileOpenDialog("", "", "All Files (*.*)") ;Find Ext $Ext = StringRegExpReplace($file, "^.*\.", ".$1") ;Read the icon place $iconplace = RegRead("HKCR\" & $Ext, "") ;Test if icon place exists If $iconplace Then ;Get icon string format is PATH,ORD $icon = RegRead("HKCR\" & $iconplace & "\DefaultIcon", "") Else ;Get icon string format is PATH,ORD $icon = RegRead("HKCR\" & $Ext & "\DefaultIcon", "") EndIf MsgBox (0, "", $icon) ;Split string $split = StringSplit($icon, ",") ;Icon path, replace " $icon_file = StringReplace ($split[1], '"', '') ;If string contains %SYSTEMROOT% Then we must tell AutoIt to handle it. If StringInStr ($icon_file, "%") Then ;Save the value so we can set it back $old_ExpandEnvStrings = Opt ("ExpandEnvStrings", 1) EndIf ;Icon $icon_ord = $split[2] ;Set Icon $icon = GUICtrlCreateIcon($icon_file, 0 - $icon_ord, 20, 20) ;Set it back Opt ("ExpandEnvStrings", $old_ExpandEnvStrings) ;Show GUI GUISetState() ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then Exit WEnd;Find Ext $Ext = StringRegExpReplace($file, "^.*\.", ".$1") ?????? ;Find Ext $Ext = StringRegExpReplace($file, "^.*(\..+)$", "$1") 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...
Inverted Posted June 18, 2009 Share Posted June 18, 2009 Still doesn't work ? Do I select any exe file that has an ico ? Link to comment Share on other sites More sharing options...
corgano Posted June 18, 2009 Author Share Posted June 18, 2009 I also get %1 useing this: Func _GetIcon($file, $ReturnType = 0) $FileType = StringSplit($file, ".") $FileType = $FileType[UBound($FileType) - 1] $FileParam = RegRead("HKEY_CLASSES_ROOT\." & $FileType, "") $DefaultIcon = RegRead("HKEY_CLASSES_ROOT\" & $FileParam & "\DefaultIcon", "") If Not @error Then $IconSplit = StringSplit($DefaultIcon, ",") ReDim $IconSplit[3] $Iconfile = $IconSplit[1] $IconID = $IconSplit[2] Else $Iconfile = @SystemDir & "\shell32.dll" $IconID = -219 EndIf If $ReturnType = 0 Then Return $Iconfile Else Return $IconID EndIf EndFunc ;==>_GetIcon how do i fix this so the returned value can be used with guictrlcreateicon()? 0x616e2069646561206973206c696b652061206d616e20776974686f7574206120626f64792c20746f206669676874206f6e6520697320746f206e657665722077696e2e2e2e2e Link to comment Share on other sites More sharing options...
ProgAndy Posted June 18, 2009 Share Posted June 18, 2009 It should be: $AutoItIconIndex = -($IconID+1) *GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes Link to comment Share on other sites More sharing options...
dantay9 Posted June 18, 2009 Share Posted June 18, 2009 I haven't examined this script yet, but it works. Take a look at how this script works. Link to comment Share on other sites More sharing options...
Yashied Posted June 18, 2009 Share Posted June 18, 2009 http://www.autoitscript.com/forum/index.php?s=&showtopic=94207&view=findpost&p=676868 My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More... Link to comment Share on other sites More sharing options...
corgano Posted June 18, 2009 Author Share Posted June 18, 2009 (edited) I haven't examined this script yet, but it works. Take a look at how this script works.My previous script was from there. try opening exe's or other files (like .RAR archives). I need one that will always work.http://www.autoitscript.com/forum/index.php?s=&showtopic=94207&view=findpost&p=676868WOW. This will work perfectly. All I need now is getting the icon of an exe. Edited June 18, 2009 by corgano 0x616e2069646561206973206c696b652061206d616e20776974686f7574206120626f64792c20746f206669676874206f6e6520697320746f206e657665722077696e2e2e2e2e Link to comment Share on other sites More sharing options...
dantay9 Posted June 18, 2009 Share Posted June 18, 2009 Sorry. I didn't look into the script, I just had the program so I posted it. I did find out that .exe files wont work. Link to comment Share on other sites More sharing options...
Valuater Posted June 18, 2009 Share Posted June 18, 2009 .... All I need now is getting the icon of an exe.This does it the easy way!!http://www.autoitscript.com/forum/index.ph...st&p=3057488) Link to comment Share on other sites More sharing options...
corgano Posted June 18, 2009 Author Share Posted June 18, 2009 (edited) Sorry. I didn't look into the script, I just had the program so I posted it. I did find out that .exe files wont work.Thats the odd thing about that script. Sometimes they do, sometimes they don't.This does it the easy way!!http://www.autoitscript.com/forum/index.ph...st&p=3057488)Could you take the part out that gets the icon and put it in a standalone example? I couldnt find what part it was. Edited June 18, 2009 by corgano 0x616e2069646561206973206c696b652061206d616e20776974686f7574206120626f64792c20746f206669676874206f6e6520697320746f206e657665722077696e2e2e2e2e Link to comment Share on other sites More sharing options...
Valuater Posted June 18, 2009 Share Posted June 18, 2009 Maybe... #include <GUIConstantsEx.au3> #include <ButtonConstants.au3> GUICreate("My GUI") ; will create a dialog box that when displayed is centered GUICtrlCreateButton("my picture button", 10, 20, 40, 40, $BS_ICON) GUICtrlSetImage(-1, @WindowsDir & "\notepad.exe", "", 1) GUISetState() While GUIGetMsg() <> -3 WEnd 8) Link to comment Share on other sites More sharing options...
corgano Posted June 18, 2009 Author Share Posted June 18, 2009 (edited) Maybe... #include <GUIConstantsEx.au3> #include <ButtonConstants.au3> GUICreate("My GUI") ; will create a dialog box that when displayed is centered GUICtrlCreateButton("my picture button", 10, 20, 40, 40, $BS_ICON) GUICtrlSetImage(-1, @WindowsDir & "\notepad.exe", "", 1) GUISetState() While GUIGetMsg() <> -3 WEnd 8) Found problem. I am useing guictrlcreateicon() #include <GUIConstantsEx.au3> #include <ButtonConstants.au3> GUICreate("My GUI"); will create a dialog box that when displayed is centered ;$icon = GUICtrlCreateButton("my picture button", 10, 20, 40, 40, $BS_ICON) $icon = GUICtrlCreateIcon("","", 1, 2) $file = FileOpenDialog("123",@DesktopDir,"all files(*.*)") GUICtrlSetImage($icon, $file , "", 1) GUISetState() While GUIGetMsg() <> -3 WEnd Works fine with button, but doesnt work with icon Edited June 18, 2009 by corgano 0x616e2069646561206973206c696b652061206d616e20776974686f7574206120626f64792c20746f206669676874206f6e6520697320746f206e657665722077696e2e2e2e2e Link to comment Share on other sites More sharing options...
Valuater Posted June 18, 2009 Share Posted June 18, 2009 Did you look at the example in help?? I just added notepad...... thats all!! GUICreate(" My GUI Icons", 250, 250) $icon = GUICtrlCreateIcon("shell32.dll", 10, 20, 20) $n1 = GUICtrlCreateIcon(@WindowsDir & "\cursors\horse.ani", -1, 20, 40, 32, 32) $n2 = GUICtrlCreateIcon("shell32.dll", 7, 20, 75, 32, 32) $n2 = GUICtrlCreateIcon(@WindowsDir & "\notepad.exe", -1, 20, 115, 32, 32) GUISetState() While GUIGetMsg() <> -3 WEnd 8) Link to comment Share on other sites More sharing options...
corgano Posted June 18, 2009 Author Share Posted June 18, 2009 For anyone wanting to know why I need this, I have included the script i am going to add it to.icon_box.au3 0x616e2069646561206973206c696b652061206d616e20776974686f7574206120626f64792c20746f206669676874206f6e6520697320746f206e657665722077696e2e2e2e2e 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