Jump to content

Help Using #AutoIt3Wrapper_Res_Icon_Add


Recommended Posts

Ok so I guess I can't figure this out. Maybe I am over looking something obvious.

I want to embed a logo image in my executable. I converted it from a transparent jpeg to an icon and am using #AutoIt3Wrapper_Res_Icon_Add to add it in at compile time. With reshacker I can see the resource. But what I guess I don't know or can't figure out is how to then use this compiled resource in my script.

Here is the sample code I wrote:

#Region;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Res_Icon_Add=E:\~ Personal\Development\Scripting\DoD Source Match Calculator\Images\logo.ico
#EndRegion;**** Directives created by AutoIt3Wrapper_GUI ****

;Include items
#include <GUIConstants.au3>


#Region ### START Koda GUI section ### Form=c:\program files\autoit3\koda_1.6.0.2\forms\source calc.kxf
$SourceCalc = GUICreate("DoD:S Match Calculator", 337, 267, 241, 175)

$Quit = GUICtrlCreateButton("Quit", 208, 216, 123, 25, 0)

If @Compiled = 1 Then
      GUICtrlCreateIcon(@ScriptFullPath, 50, 208, 8, 124, 76)
Else
    GUICtrlCreateIcon("..\Images\logo.ico", 50, 208, 8, 124, 76)
EndIf

GUISetState(@SW_SHOW,$SourceCalc)
#EndRegion ### END Koda GUI section ###

;Main Application
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
    
        Case $Quit
            Exit

    EndSwitch
WEnd

Exit

As you can see I have my logo icon being added with #AutoIt3Wrapper_Res_Icon_Add=E:\~ Personal\Development\Scripting\DoD Source Match Calculator\Images\logo.ico.

I think used reshacker to see what the number the resource was given (here is where I am guessing). It is 50 so I used it and when compiling the script it doesn't show up. I have also tried most of the single digit numbers and a few negatives to see if I stumble on my icon which I have not. Could someone clue me in here on how this works.

Here is my reshacker screencap:

Posted Image

This is what my program should look like:

Posted Image

This is what it looks like after compiling:

Posted Image

Also I have spent the last week searching the forums for help and haven't found anything to solve my issues. Though I have found every questions I have had answered via searching the forums so far. I am also new to scripting in AutoIt and this is my first real in depth script I have attempted (previously I had been scripting in a different language, but am converting over).

Thanks for any and all help.

chris

...

Link to comment
Share on other sites

Ah I am an idiot... I even read that like 3 times figuring it had to be in there.

;Add extra ICO files to the resources which can be used with TraySetIcon(@ScriptFullPath, 3) etc

; list of filename of the Ico files to be added, First one will have number 3, then 4 ..etc

But I updated my code to be the following and after compiling I still don't see it. :whistle: Did I miss something else?

Here is the updated code segment:

#Region;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Res_Icon_Add=E:\~ Personal\Development\Scripting\DoD Source Match Calculator\Images\logo.ico
#EndRegion;**** Directives created by AutoIt3Wrapper_GUI ****

;Include items
#include <GUIConstants.au3>


#Region ### START Koda GUI section ### Form=c:\program files\autoit3\koda_1.6.0.2\forms\source calc.kxf
$SourceCalc = GUICreate("DoD:S Match Calculator", 337, 267, 241, 175)

$Quit = GUICtrlCreateButton("Quit", 208, 216, 123, 25, 0)

If @Compiled = 1 Then
      GUICtrlCreateIcon(@ScriptFullPath, 3, 208, 8, 124, 76)
Else
    GUICtrlCreateIcon("..\Images\logo.ico", 3, 208, 8, 124, 76)
EndIf

GUISetState(@SW_SHOW,$SourceCalc)
#EndRegion ### END Koda GUI section ###

;Main Application
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
    
        Case $Quit
            Exit

    EndSwitch
WEnd

Exit

As for my icon, I created the logo in Photoshop so I didn't convert the GIF to an icon I actually converted the original PSD to an icon. I used GIF Movie Gear to do it.

chris

...

Link to comment
Share on other sites

Just a quick thought.. have you tried shortening the path to the files you are referencing? I don't like the look of the path to your ico

[u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote]

Link to comment
Share on other sites

Just a quick thought.. have you tried shortening the path to the files you are referencing? I don't like the look of the path to your ico

I got an error when I provided the following path and it wouldn't compile the resource in when I used this "..\Images\logo.ico"

Also changing it to this "#AutoIt3Wrapper_Res_Icon_Add=C:\logo.ico" did fix the issue. Also I am fairly sure the path isn't an issue as I can use reshacker to see icon resource as demonstrated above in the reshacker screen shot.

I did try it, so thanks for the suggestion.

chris

PS - Thanks Zedna for the link to the documentation and the kick in the butt to go read it again.

...

Link to comment
Share on other sites

Have you tried if the ICO file you created works by using it as seperate file ?

Do you mean using it like this?

GUICtrlCreateIcon("..\Images\logo.ico", 3, 208, 8, 124, 76)

This works without issue. But you bring up a good point. I should try loading in a different icon file as a test to see if I can get that to load at compile time.

thanks for the suggestion. If I didn't get your suggestion correctly feel free correct me so I understand what you are suggesting.

chris

...

Link to comment
Share on other sites

instead of:

GUICtrlCreateIcon(@ScriptFullPath, 3, 208, 8, 124, 76)oÝ÷ ÚÚòjëh×6GUICtrlCreateIcon(@ScriptFullPath, -4, 208, 8, 124, 76)

HelpFile: GUICtrlCreateIcon

Passing a positive number will reference the string equivalent icon name.

Passing a negative number causes 1-based "index" behaviour. Some Dll can have icon extracted just with negative numbers.

Link to comment
Share on other sites

Zedna you rock! That worked, well kinda. Looks like crap but something showed up. I will look into why it looks like crap Thursday. I will re-read that quote but I guess I am a little confused by the difference in the positive and negative 1-base reference. But I don't need to understand everything as long as it works.

Another problem down, a new one to solve.

Posted Image

Thanks again for the help

chris

...

Link to comment
Share on other sites

  • 1 year later...

Sorry to resurrect a dead thread, but this got me confused for a couple of hours too trying to get TraySetIcon working.

I'm pretty sure most people trying to use this function will also encounter some confusion when trying to reference their icons.

The negative number thing doesn't really seem to be all that apparent and a lot of people will miss that reference in the "Remarks".

Passing a positive number will reference the string equivalent icon name.

Passing a negative number causes 1-based "index" behaviour. Some Dll can have icon extracted just with negative numbers.

Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

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