Use Icons in compiled scripts

Get help with using AutoHotkey and its commands and hotkeys
Peter2
Posts: 252
Joined: 21 Sep 2014, 14:38
Location: CH

Use Icons in compiled scripts

16 Jan 2015, 06:15

I'm searching for the right workflow to do this:

I have:
- an AHK file
- usage of Icons like "Menu, Tray, Icon, Pdf.ico" and "SB_SetIcon("pdf16.ico",,1)"
- the needed ICO-files in the same folder
-> it works fine

I want to:
- compile the script
- use the "new" AHK2EXE (http://ahkscript.org/boards/viewtopic.php?f=24&t=521)
- embed the ICO into the EXE to get a single file

I need to now:
- how to integrate the ICO in the EXE. ICO is not yet supported by the compiler, but BMP and DIB. And DLL (??? never made it) and SCR (Scrennsaver?)
- how to call it from the AHK-code?

Thanks in advance
Peter (AHK Beginner) / Win 7 x64, AHK Version v1.1.22.xx
Guest

Re: Use Icons in compiled scripts

16 Jan 2015, 07:32

You can http://ahkscript.org/docs/commands/FileInstall.htm to include the icon in your exe so when the exe is run the ICO is extracted and you can use it.
Peter2
Posts: 252
Joined: 21 Sep 2014, 14:38
Location: CH

Re: Use Icons in compiled scripts

16 Jan 2015, 09:52

Thanks
Yes, "Fileinstall" is the perfect way for another idea and a 90%-perfect way for this topic (it works, but it creates files).

If someone can solve the other 10% (the real integration into the EXE) it would be great.
Peter (AHK Beginner) / Win 7 x64, AHK Version v1.1.22.xx
User avatar
Flipeador
Posts: 1173
Joined: 15 Nov 2014, 21:31
GitHub: Flipeador
Location: Argentina
Contact:

Re: Use Icons in compiled scripts

16 Jan 2015, 10:13

in my opinion 'FileInstall' works well, but is not exactly what I wanted. I think the issue is, how to use the files (.bmp, .png, etc.) included in the .exe file. and, moreover, will have to wait for a new update of the 'new' AHK2EXE.
MJs
Posts: 454
Joined: 23 Sep 2014, 03:29

Re: Use Icons in compiled scripts

16 Jan 2015, 18:37

if you want to get dirty with some work aroundsssssss, not one around
it's a stretch, but AHK has the ability to read icons from executable files, so why not itself also
so:
- read untill the end..
- compile your script as normal, with no InstallFile for the icons
- use reshacker, from the GUI or using CLI I prefer the latter (since you can do it all in one script and RunWait the commands one after another, nice workflow as far as I'm concern)
- add the icon to your EXE file (Icon group) (keep in mind the file already has the 8 AHK default icons, you can replace them or add your new icon at the end, either case pay attention to the icon number, either 1,2... or 9,10...)
- this is the first step I left it last, just to get the picture, Now the path to your icon is the path of your EXE which is A_ScriptFullPath
after all said and done this

Code: Select all

Menu, Tray, Icon, %A_ScriptFullPath%, 9
will change the tray icon to the icon you added using the ResHacker

I tried it and i worked fine for me, so afaik it should work nicely for you too
one more thing: thank you for making me think a little about that, since I had no use for it, I didn't think of it.
don't know about the new Ahk2Exe, hope it would simplify things for you
Peter2
Posts: 252
Joined: 21 Sep 2014, 14:38
Location: CH

Re: Use Icons in compiled scripts

17 Jan 2015, 13:46

At first I thought that the usage of Ressourcehacker is a lot of work which has to be repeated always when I compile the exe again, but the following process should work automated:

- Use the ;@AHK2Exe-Postexec directive
-- which calls a batch file
--- which contains command-line command for Ressourcehacker
---- which adds the Icons you created before.

I will see.

Peter
Peter (AHK Beginner) / Win 7 x64, AHK Version v1.1.22.xx
MJs
Posts: 454
Joined: 23 Sep 2014, 03:29

Re: Use Icons in compiled scripts

17 Jan 2015, 14:34

you don't need batch file, call the commands using runwait
the commands in the patch can be called directly
even the compilong process can be done from commend line without the GUI
when I'll have some time I may try and post the script once I'm done
it's simple, just go step by step. good luck
Peter2
Posts: 252
Joined: 21 Sep 2014, 14:38
Location: CH

Re: Use Icons in compiled scripts

17 Jan 2015, 14:40

MJs wrote:you don't need batch file, call the commands using runwait...
But using RunWait inside the code is not invoked after compiling. At first I have to compile, then I have to add the icon ... :think:
Peter (AHK Beginner) / Win 7 x64, AHK Version v1.1.22.xx
MJs
Posts: 454
Joined: 23 Sep 2014, 03:29

Re: Use Icons in compiled scripts

17 Jan 2015, 14:49

use another script, seperated, to compile using ahk2exe command line params, you'll find example in docs file, and then add icons using the commands from reshacker
but the key is your original script that has to have the numbers right like the icon 9 in my example
#persistant
Menu, Tray, Icon, %A_ScriptFullPath%, 9
use just these two line for testing
Peter2
Posts: 252
Joined: 21 Sep 2014, 14:38
Location: CH

Re: Use Icons in compiled scripts

17 Jan 2015, 15:26

MJs wrote:...and then add icons using the commands from reshacker...
Yes, that's exactly want I do with the batch which is started from the compiling program
MJs wrote:... but the key is your original script that has to have the numbers right like the icon 9 in my example...
Yes. I use numbers for names of the icongroups starting with 300, because the highest number (=name) of the AHK-compiler-icons is 230. (Of course other numbers or names are possible, but I decided for me to not disturb the original order)
Peter (AHK Beginner) / Win 7 x64, AHK Version v1.1.22.xx
MJs
Posts: 454
Joined: 23 Sep 2014, 03:29

Re: Use Icons in compiled scripts

17 Jan 2015, 16:38

ok, if that works and in your work flow then use it
is it solved then?
Peter2
Posts: 252
Joined: 21 Sep 2014, 14:38
Location: CH

Re: Use Icons in compiled scripts

17 Jan 2015, 16:40

MJs wrote:...is it solved then?
I would say: 99% yes. 1% would be the full integration into AHK2Exe.

Thanks and have a fine Sunday.
Peter (AHK Beginner) / Win 7 x64, AHK Version v1.1.22.xx
MJs
Posts: 454
Joined: 23 Sep 2014, 03:29

Re: Use Icons in compiled scripts

17 Jan 2015, 16:56

you too.
I hope you'll have that missing 1% soon.

Return to “Ask For Help”

Who is online

Users browsing this forum: Google [Bot], Renets, sazd, swagfag, teadrinker, Xtra and 84 guests