How to compile with ahk2exe an icon library file (.icl) Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Snowbird_0

How to compile with ahk2exe an icon library file (.icl)

10 Feb 2016, 14:12

Hello everyone,

I would like to know how I can compile an icon library with my ahk script ? Is it possible ?

I've checked in the help file and found the following :

Code: Select all

Ahk2Exe.exe /in MyScript.ahk [/out MyScript.exe] [/icon MyIcon.ico] [/bin AutoHotkeySC.bin] [/mpress 0or1]
For example:
Ahk2Exe.exe /in "MyScript.ahk" /icon "MyIcon.ico"
The example is only for a single icon (.ico), if I try with my icon library file (.icl) I get a compilation error !

Here's what I want to do, I want to change the tray icon depending on certain variables, for example :

Code: Select all

if	 (OutputVar1 = "1N") AND (OutputVar2 = "2N") AND (OutputVar3 = "3N") AND (OutputVar4 = "4N")
	Menu, Tray, Icon, MyIcon.icl, 1
else if  (OutputVar1 = "1N") AND (OutputVar2 = "2N") AND (OutputVar3 = "3N") AND (OutputVar4 = "4G")
	Menu, Tray, Icon, MyIcon.icl, 2
else if  (OutputVar1 = "1N") AND (OutputVar2 = "2N") AND (OutputVar3 = "3G") AND (OutputVar4 = "4N")
	Menu, Tray, Icon, MyIcon.icl, 3
My script is working perfectly, and the icon changes as I wanted depending on the variables, now all I want to do is to create a single .exe file which includes my .ahk script + my .icl icon library. Is there a way to do that ? I don't want to have 2 separate files (exe + icl) to make this work.

Thank you in advance for your help/advice :)
FileInstall

Re: How to compile with ahk2exe an icon library file (.icl)

11 Feb 2016, 08:59

Have you looked at the FileInstall command? That way the ICL will be included in the exe and put it there where you want it when you run the compiled script. You can delete the ICL if you close the exe (see the OnExit command)
User avatar
menteith
Posts: 51
Joined: 04 Feb 2016, 12:22

Re: How to compile with ahk2exe an icon library file (.icl)

11 Feb 2016, 10:12

*.ico files in Windows can store many icons. Did you try this?
An ordinary user who needs some help with developing own programs for his own use.
Snowbird_0

Re: How to compile with ahk2exe an icon library file (.icl)

11 Feb 2016, 10:33

FileInstall wrote:Have you looked at the FileInstall command? That way the ICL will be included in the exe and put it there where you want it when you run the compiled script. You can delete the ICL if you close the exe (see the OnExit command)
That could be an alternate solution, not as clean as I thought, but at least it would work.
Thanks for this suggestion, if I don't find any cleaner solution I might do it this way.

There must be a way to compile several files into a single one, I'm still searching in the forum and on the web.
Snowbird_0

Re: How to compile with ahk2exe an icon library file (.icl)  Topic is solved

11 Feb 2016, 10:36

menteith wrote:*.ico files in Windows can store many icons. Did you try this?
Thanks for your help, but I'm not sure I understand well what you're trying to say, can you please give me more details ? My .icl file contains about 80 icons already.

Thank you.
User avatar
menteith
Posts: 51
Joined: 04 Feb 2016, 12:22

Re: How to compile with ahk2exe an icon library file (.icl)

12 Feb 2016, 06:39

Convert your icl to ico. In ico file multpile icons can be stored.
An ordinary user who needs some help with developing own programs for his own use.
lexikos
Posts: 9583
Joined: 30 Sep 2013, 04:07
Contact:

Re: How to compile with ahk2exe an icon library file (.icl)

12 Feb 2016, 07:01

menteith wrote:*.ico files in Windows can store many icons.
An ICO file can store many bitmaps, all intended to represent a single icon at different resolutions. No standard Windows tool or API supports multiple icons of the same resolution in an ICO file, and neither does AutoHotkey.

@Snowbird_0: I suggest you add your icons directly to your compiled exe.
Snowbird_0

Re: How to compile with ahk2exe an icon library file (.icl)

15 Feb 2016, 18:48

Hi lexikos,

thank you for the explanation about the .ico file and the relation with bitmaps, I understand better now.

As for your suggestion, when you say "add your icons directly to your compiled exe", you mean all 80 icons that I need ? of course I don't need them all at the same time, just one single icon is used and is changed among the 80 on certain criteria. How can I do this ? Should I extract all 80 icons from my .icl library to compile them all 80 with the ahk script ? or should put them beside the compiled script ? In this last case, it will of course look very "ugly" :).

Thanks again for your time.
lexikos
Posts: 9583
Joined: 30 Sep 2013, 04:07
Contact:

Re: How to compile with ahk2exe an icon library file (.icl)

15 Feb 2016, 19:08

You can use a Win32 resource editor such as Resource Hacker to add the icons directly to the compiled exe. You will probably need to extract each icon to an .ico file first. Resource Hacker can be driven by command line, so you can automate the process of compiling and adding icons.

You can also try extracting each icon to an .ico file and embedding it with ;@Ahk2Exe-AddResource FileName.ico using the upcoming version of Ahk2Exe. I'm not sure if the "preview" download includes .ico support yet; you can get the source code from GitHub (Ahk2Exe itself is just a script).

Once the icons are embedded in the exe, they can be loaded the same way as from the .icl file. Just change the filename (and probably icon numbers).
Snowbird
Posts: 3
Joined: 10 Feb 2016, 13:46

Re: How to compile with ahk2exe an icon library file (.icl)

13 Jan 2018, 06:10

Hello,

2 years have passed, and I'm wondering if in the meantime there was a way to create a single .exe file that includes my .ahk script + my .icl icon library. Is there a way to do that or it's still impossible ? I don't want to have 2 separate files (exe + icl) to make this work.

Thank you
Snowbird
Posts: 3
Joined: 10 Feb 2016, 13:46

Re: How to compile with ahk2exe an icon library file (.icl)

15 Jan 2018, 12:32

Thanks for your reply, but I'm not sure I understand how and what to do, can you please elaborate a little ?
Thank you.
Guest

Re: How to compile with ahk2exe an icon library file (.icl)

15 Jan 2018, 14:34

Alternative: why not use FileInstall to install the ICL file, and simple delete it when the App is closed (See the OnExit command). Keep it simple :-)
Snowbird
Posts: 3
Joined: 10 Feb 2016, 13:46

Re: How to compile with ahk2exe an icon library file (.icl)

16 Jan 2018, 04:37

Thanks, I will have a look at it.

But honestly it's hard to imagine that AHK can not include an ICL file, no one has ever done that ? is there any AHK guru around that has a tip about this ?
Guest

Re: How to compile with ahk2exe an icon library file (.icl)

16 Jan 2018, 04:51

Just to clear: FileInstall does include the ICL (and other files), so you only have to copy / send someone the exe and they have all the files they need to run the application. I'm assuming you just want to keep it one file which is why you can delete the ICL when you close the App but that is of course not required.

I don't understand the "obsession" to have it all in one file as such, you can already do that (and have since the fileinstall/onexit commands were added to AutoHotkey back in the day)

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: No registered users and 221 guests