Jump to content

How to show a icon in the EXE-file


Go to solution Solved by AutoBert,

Recommended Posts

Posted (edited)

using

GUISetIcon(@SystemDir & '\shell32.dll', -140, $hGui)

is showing the refereced icon in the title bar.

236_ScreenShooter.jpg

 But i want same icon on the EXE-icon, using 

#AutoIt3Wrapper_Res_Icon_Add=C:\WINDOWS\system32\shell32.dll -140

 

 

causes error

- => Skipping #AutoIt3Wrapper_Res_Icon_Add because the Ico file is not found:"C:\WINDOWS\system32\shell32.dll -140"
-> No changes made..

and so the standard exe-icon is used for the desktop-link.

 

Edited by AutoBert
Posted (edited)

I guess you have to extract the .ICO file (e.g. with ResHacker) and use it directly.

Edit : @Zedna was quicker :)

Edited by Musashi

Musashi-C64.png

"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."

Posted

You can get the right icon as shown in this example. Run the example as 64 bit code. Drag the Desktop icon into the empty ListView. The correct icon should be displayed in the ListView. You can now modify the technique for your own code.

Posted
2 hours ago, Zedna said:

Solution: 

Extract ICO file from DLL by some external utility and use this ICO file in AU3Wrapper ResIconAdd syntax.

Maybe i misinterpreted this: 

Quote

; Add extra ICO files to the resources which can be used with TraySetIcon(@ScriptFullPath, 5) etc
#AutoIt3Wrapper_Res_Icon_Add=                   ; Filename[,ResNumber[,LanguageCode]] of ICO to be added.
; Add extra ICO files to the resources
; Use full path of the ico files to be added
; ResNumber is a numeric value used to access the icon: TraySetIcon(@ScriptFullPath, ResNumber)
;

a simply renaming to .ico and using

#AutoIt3Wrapper_Res_Icon_Add=Shell32.ico, 140

ls accepted by Wrapper but causes a hanging compiler manualy Tool -> Stop executing.

 

@LarsJ Have you a example how to save a Icon from a _GUIImageList_Create to disk? Without it's useless for me

Posted

Can't you just use one of the usual functions to save an icon from the handle in the $tagSHFILEINFO structure?

Posted (edited)
10 hours ago, argumentum said:

...there's a working example in ControlViewer if you care to look at the source.

I downloaded the ControlViewer(source v0.2021.02.28).zip but there are some files missing:

>"C:\Program Files (x86)\AutoIt3\SciTE\..\AutoIt3.exe" "C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.au3" /run /prod /ErrorStdOut /in "C:\Users\(len)Bert\AutoIt\Downloaded\Argumentum\ControlViewer(source v0.2021.02.28)\CV.au3" /UserParams    
+>13:55:56 Starting AutoIt3Wrapper (21.316.1639.1) from:SciTE.exe (4.4.6.0)  Keyboard:00000407  OS:WIN_10/2009  CPU:X64 OS:X64  Environment(Language:0407)  CodePage:0  utf8.auto.check:4
+>         SciTEDir => C:\Program Files (x86)\AutoIt3\SciTE   UserDir => C:\Users\(len)Bert\AppData\Local\AutoIt v3\SciTE\AutoIt3Wrapper   SCITE_USERHOME => C:\Users\(len)Bert\AppData\Local\AutoIt v3\SciTE 
!->Includefile <ColorPicker.au3> not found.
!->Includefile <FMIPC.au3> not found.
>Running AU3Check (3.3.16.0)  params:-q -d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7  from:C:\Program Files (x86)\AutoIt3  input:C:\Users\(len)Bert\AutoIt\Downloaded\Argumentum\ControlViewer(source v0.2021.02.28)\CV.au3
"C:\Users\(len)Bert\AutoIt\Downloaded\Argumentum\ControlViewer(source v0.2021.02.28)\UDFs\ColorChooser.au3"(112,117) : warning: 'Dim' deprecated as declaration. Prefer to use Local or Global.
Dim $ccData[29] = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, Default, Default, 0, 0]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"C:\Users\(len)Bert\AutoIt\Downloaded\Argumentum\ControlViewer(source v0.2021.02.28)\UDFs\ColorChooser.au3"(150,35) : warning: 'Dim' deprecated as declaration. Prefer to use Local or Global.
Dim $ccPalette[21][3] = [[0, 1, 0]]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"C:\Users\(len)Bert\AutoIt\Downloaded\Argumentum\ControlViewer(source v0.2021.02.28)\UDFs\ColorChooser.au3"(829,13) : warning: $ARGB: declared, but not used in func.
    Local $ARGB,
    ~~~~~~~~~~~^
"C:\Users\(len)Bert\AutoIt\Downloaded\Argumentum\ControlViewer(source v0.2021.02.28)\UDFs\ColorChooser.au3"(1472,38) : warning: $iMsg: declared, but not used in func.
Func CC_WM_NCRBUTTONDOWN($hWnd, $iMsg,
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"C:\Users\(len)Bert\AutoIt\Downloaded\Argumentum\ControlViewer(source v0.2021.02.28)\UDFs\ColorChooser.au3"(1472,56) : warning: $lParam: declared, but not used in func.
Func CC_WM_NCRBUTTONDOWN($hWnd, $iMsg, $wParam, $lParam)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"C:\Users\(len)Bert\AutoIt\Downloaded\Argumentum\ControlViewer(source v0.2021.02.28)\UDFs\ColorChooser.au3"(1521,35) : warning: $iMsg: declared, but not used in func.
Func CC_WM_SYSCOMMAND($hWnd, $iMsg,
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"C:\Users\(len)Bert\AutoIt\Downloaded\Argumentum\ControlViewer(source v0.2021.02.28)\UDFs\ColorChooser.au3"(1521,53) : warning: $lParam: declared, but not used in func.
Func CC_WM_SYSCOMMAND($hWnd, $iMsg, $wParam, $lParam)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"C:\Users\(len)Bert\AutoIt\Downloaded\Argumentum\ControlViewer(source v0.2021.02.28)\UIA\CUIAutomation2.au3"(2,70) : warning: $sCLSID_UIAutomationClient possibly not declared/created yet
$sCLSID_UIAutomationClient = "{944DE083-8FB8-45CF-BCB7-C477ACB2F897}"
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"C:\Users\(len)Bert\AutoIt\Downloaded\Argumentum\ControlViewer(source v0.2021.02.28)\UIA\CUIAutomation2.au3"(834,7) : warning: 'Local' specifier in global scope.
Local $UIA_propertiesSupportedArray
~~~~~~^
"C:\Users\(len)Bert\AutoIt\Downloaded\Argumentum\ControlViewer(source v0.2021.02.28)\UIA\CUIAutomation2.au3"(953,7) : warning: 'Local' specifier in global scope.
Local $UIA_ControlArray
~~~~~~^
"C:\Users\(len)Bert\AutoIt\Downloaded\Argumentum\ControlViewer(source v0.2021.02.28)\UIA\UIAWrappers.au3"(12,7) : warning: 'Local' specifier in global scope.
Local $UIA_oUIAutomation
~~~~~~^
"C:\Users\(len)Bert\AutoIt\Downloaded\Argumentum\ControlViewer(source v0.2021.02.28)\UIA\UIAWrappers.au3"(14,7) : warning: 'Local' specifier in global scope.
Local Const
~~~~~~^
"C:\Users\(len)Bert\AutoIt\Downloaded\Argumentum\ControlViewer(source v0.2021.02.28)\UIA\UIAWrappers.au3"(15,7) : warning: 'Local' specifier in global scope.
Local Const
~~~~~~^
"C:\Users\(len)Bert\AutoIt\Downloaded\Argumentum\ControlViewer(source v0.2021.02.28)\UIA\UIAWrappers.au3"(16,7) : warning: 'Local' specifier in global scope.
Local Const
~~~~~~^
"C:\Users\(len)Bert\AutoIt\Downloaded\Argumentum\ControlViewer(source v0.2021.02.28)\UIA\UIAWrappers.au3"(19,7) : warning: 'Local' specifier in global scope.
Local Const
~~~~~~^
"C:\Users\(len)Bert\AutoIt\Downloaded\Argumentum\ControlViewer(source v0.2021.02.28)\UIA\UIAWrappers.au3"(107,98) : warning: $t: declared, but not used in func.
    Local $t = _UIA_GetDesktopElement().FindFirst($TreeScope_Children, $pCondition, $UIA_pUIElement)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"C:\Users\(len)Bert\AutoIt\Downloaded\Argumentum\ControlViewer(source v0.2021.02.28)\UIA\UIAWrappers.au3"(159,102) : warning: $UIA_oTW possibly not declared/created yet
    $UIA_oTW = ObjCreateInterface($UIA_pTW, $sIID_IUIAutomationTreeWalker, $dtagIUIAutomationTreeWalker)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"C:\Users\(len)Bert\AutoIt\Downloaded\Argumentum\ControlViewer(source v0.2021.02.28)\UIA\UIAutomation.au3"(30,62) : warning: $flag: declared, but not used in func.
Func _UIA_ControlSetText($h_wnd, $controlID, $text, $flag = 0)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"C:\Users\(len)Bert\AutoIt\Downloaded\Argumentum\ControlViewer(source v0.2021.02.28)\UIA\UIAutomation.au3"(51,71) : warning: $sText already declared/assigned
    Local $sText = _UIA_GetPropertyValue($controlID, $UIA_NamePropertyId)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"C:\Users\(len)Bert\AutoIt\Downloaded\Argumentum\ControlViewer(source v0.2021.02.28)\UIA\UIAutomation.au3"(63,85) : warning: $currentState possibly not declared/created yet
    $currentState = _UIA_GetPropertyValue($controlID, $UIA_ToggleToggleStatePropertyId)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"C:\Users\(len)Bert\AutoIt\Downloaded\Argumentum\ControlViewer(source v0.2021.02.28)\UIA\UIAutomation.au3"(85,72) : warning: $tPattern possibly not declared/created yet
        $tPattern = _UIA_CreateControlPattern($controlID, $UIA_InvokePattern)
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"C:\Users\(len)Bert\AutoIt\Downloaded\Argumentum\ControlViewer(source v0.2021.02.28)\UIA\UIAutomation.au3"(90,80) : warning: $aBound possibly not declared/created yet
        $aBound = _UIA_GetPropertyValue($controlID, $UIA_BoundingRectanglePropertyId)
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"C:\Users\(len)Bert\AutoIt\Downloaded\Argumentum\ControlViewer(source v0.2021.02.28)\UIA\UIAutomation.au3"(156,55) : warning: $ret possibly not declared/created yet
            $ret = __UIA_ControlSearch($searchRoot, $controlID)
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"C:\Users\(len)Bert\AutoIt\Downloaded\Argumentum\ControlViewer(source v0.2021.02.28)\UIA\UIAutomation.au3"(191,97) : warning: $searchStringKvPairs possibly not declared/created yet
    $searchStringKvPairs = StringRegExp($searchString, $_UIA_Regex_ControlId_SplitKeyValuePairs, 3)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"C:\Users\(len)Bert\AutoIt\Downloaded\Argumentum\ControlViewer(source v0.2021.02.28)\UIA\UIAutomation.au3"(197,37) : warning: $kvPair possibly not declared/created yet
        $kvPair = $searchStringKvPairs[$i]
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"C:\Users\(len)Bert\AutoIt\Downloaded\Argumentum\ControlViewer(source v0.2021.02.28)\UIA\UIAutomation.au3"(198,37) : warning: $split possibly not declared/created yet
        $split = StringInStr($kvPair, ":")
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"C:\Users\(len)Bert\AutoIt\Downloaded\Argumentum\ControlViewer(source v0.2021.02.28)\UIA\UIAutomation.au3"(199,41) : warning: $key possibly not declared/created yet
        $key = StringLeft($kvPair, $split - 1)
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"C:\Users\(len)Bert\AutoIt\Downloaded\Argumentum\ControlViewer(source v0.2021.02.28)\UIA\UIAutomation.au3"(200,42) : warning: $value possibly not declared/created yet
        $value = StringMid($kvPair, $split + 1)
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"C:\Users\(len)Bert\AutoIt\Downloaded\Argumentum\ControlViewer(source v0.2021.02.28)\UIA\UIAutomation.au3"(211,22) : warning: $pCondition already declared/assigned
                Local $pCondition
                ~~~~~~~~~~~~~~~~~^
"C:\Users\(len)Bert\AutoIt\Downloaded\Argumentum\ControlViewer(source v0.2021.02.28)\UIA\UIAutomation.au3"(219,72) : warning: $parsed possibly not declared/created yet
                $parsed = StringRegExp($value, $UIA_Regex_ControlId_ClassNameNN, 1)
                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"C:\Users\(len)Bert\AutoIt\Downloaded\Argumentum\ControlViewer(source v0.2021.02.28)\UIA\UIAutomation.au3"(222,24) : warning: $class possibly not declared/created yet
                $class = $parsed[0]
                ~~~~~~~~~~~~~~~~~~~^
"C:\Users\(len)Bert\AutoIt\Downloaded\Argumentum\ControlViewer(source v0.2021.02.28)\UIA\UIAutomation.au3"(226,22) : warning: $pCondition already declared/assigned
                Local $pCondition
                ~~~~~~~~~~~~~~~~~^
"C:\Users\(len)Bert\AutoIt\Downloaded\Argumentum\ControlViewer(source v0.2021.02.28)\UIA\UIAutomation.au3"(231,22) : warning: $pCondition already declared/assigned
                Local $pCondition
                ~~~~~~~~~~~~~~~~~^
"C:\Users\(len)Bert\AutoIt\Downloaded\Argumentum\ControlViewer(source v0.2021.02.28)\UIA\UIAutomation.au3"(254,58) : warning: $pCondition already declared/assigned
        Local $pAndCondition = $pConditions[0], $pCondition = 0
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"C:\Users\(len)Bert\AutoIt\Downloaded\Argumentum\ControlViewer(source v0.2021.02.28)\UIA\UIAutomation.au3"(268,124) : warning: $oAutomationElementArray possibly not declared/created yet
    $oAutomationElementArray = ObjCreateInterface($pElements, $sIID_IUIAutomationElementArray, $dtagIUIAutomationElementArray)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"C:\Users\(len)Bert\AutoIt\Downloaded\Argumentum\ControlViewer(source v0.2021.02.28)\UIA\UIAutomation.au3"(285,95) : warning: $oFound possibly not declared/created yet
        $oFound = ObjCreateInterface($pFound, $sIID_IUIAutomationElement, $dtagIUIAutomationElement)
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"C:\Users\(len)Bert\AutoIt\Downloaded\Argumentum\ControlViewer(source v0.2021.02.28)\UIA\UIAutomation.au3"(291,74) : warning: $tValuePattern possibly not declared/created yet
            $tValuePattern = _UIA_CreateControlPattern($oFound, $UIA_ValuePattern)
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"C:\Users\(len)Bert\AutoIt\Downloaded\Argumentum\ControlViewer(source v0.2021.02.28)\UIA\UIAutomation.au3"(306,121) : warning: $aBound possibly not declared/created yet
            $aBound = _UIA_GetPropertyValue($oFound, $UIA_BoundingRectanglePropertyId) ; $aBound[0] = X [1] = Y, [2] = W, [3] = H
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"C:\Users\(len)Bert\AutoIt\Downloaded\Argumentum\ControlViewer(source v0.2021.02.28)\UIA\UIAutomation.au3"(309,85) : warning: $aWinBound possibly not declared/created yet
            $aWinBound = _UIA_GetPropertyValue($searchRoot, $UIA_BoundingRectanglePropertyId)
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"C:\Users\(len)Bert\AutoIt\Downloaded\Argumentum\ControlViewer(source v0.2021.02.28)\CV.au3"(202,10) : error: can't open include file <FMIPC.au3>.
#include <FMIPC.au3>
~~~~~~~~~^
"C:\Users\(len)Bert\AutoIt\Downloaded\Argumentum\ControlViewer(source v0.2021.02.28)\CV.au3"(223,57) : error: _FMIPC_Create(): undefined function.
_FMIPC_Create(StringStripWS($GUI_UNIQUE & @UserName, 8))
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"C:\Users\(len)Bert\AutoIt\Downloaded\Argumentum\ControlViewer(source v0.2021.02.28)\CV.au3"(225,74) : error: _FMIPC_Write(): undefined function.
    _FMIPC_Write(StringStripWS($GUI_UNIQUE & @UserName, 8), "DoSelfShow", 2)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"C:\Users\(len)Bert\AutoIt\Downloaded\Argumentum\ControlViewer(source v0.2021.02.28)\CV.au3"(448,18) : error: _FMIPC_Close(): undefined function.
            _FMIPC_Close()
            ~~~~~~~~~~~~~~^
"C:\Users\(len)Bert\AutoIt\Downloaded\Argumentum\ControlViewer(source v0.2021.02.28)\CV.au3"(1348,34) : error: _FMIPC_Read(): undefined function.
    If "DoSelfShow" = _FMIPC_Read() Then
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Users\(len)Bert\AutoIt\Downloaded\Argumentum\ControlViewer(source v0.2021.02.28)\CV.au3 - 5 error(s), 39 warning(s)
!>13:56:05 AU3Check ended. Press F4 to jump to next error.rc:2
+>13:56:05 AutoIt3Wrapper Finished.
>Exit code: 2    Time: 11.01

 

Edited by AutoBert
  • Solution
Posted (edited)

i found the easiest way

 

in my iconLVw.au3i  insert this func to save the icon:

Func _SaveToFile($sDLLName, $iIconId, $iWidth=32, $iHeight=32)
    ;ConsoleWrite($sDLLName & @TAB & $iIconId & @CRLF)
    Local $sFile = $sIconPath & '\' & StringReplace($sDLLName, '.dll', '_') & $iIconId & '.ico'
    ConsoleWrite($sFile & @CRLF)
    Local $hIcon = _WinAPI_ShellExtractIcon(@SystemDir & '\' & $sDLLName, $iIconId, $iWidth, $iHeight)
    _WinAPI_SaveHICONToFile($sFile, $hIcon)
    _WinAPI_DestroyIcon($hIcon)
EndFunc   ;==>_SaveToFile

in the showing loop i inserted:

; _SaveToFile($sDLLName, $iBilder)  ;comment out and every icon in loop is saved in 32x32

no i have 3k+ icon's

 

Edited by AutoBert

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...