Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

[OLD] fincs' scripted Ahk2Exe rewrite (with GUI) - r3


  • This topic is locked This topic is locked
71 replies to this topic
fincs
  • Moderators
  • 1662 posts
  • Last active:
  • Joined: 05 May 2007
This thread is obsolete since this is now an official part of AutoHotkey

Contents preserved below:
Hi,

Some months ago I started writing a scripted clone of Ahk2Exe. Now that 32-bit scripts also use the resource method and there's a(n incomplete) scripted rewrite out there, I got the motivation to finish it.

screen_r2.png

If you're thinking, "Wow, it looks exactly the same as the existing Ahk2Exe!"; well, that's exactly the point of it! Everything has been faithfully cloned (I hope), up to the error messages!

Bundled with AutoHotkey_L
GitHub repo

What's supported
Everything: command line, #Include, FileInstall, StdLib (with #include <...> support too), icon changing (!), settings on registry...

Extra features

  • Script size reduction is now more thorough: empty lines and leading and trailing whitespace are removed, except in continuation sections.
  • Multiple .bin file support in the GUI: for it to work you must have bin files other than AutoHotkeySC.bin in the Compiler folder (in the screenshot above, I had ANSI 32-bit.bin, Unicode 32-bit.bin and Unicode 64-bit.bin).
Todo list
Implement Handle FileInstall on same-line If* commands.

Not supported (yet?)
#CommentFlag, #Delimiter, ...

Old pre-bundling changelog
r3:

  • Added missing 'v' to <COMPILER: ...> comment in compiled scripts
  • Added Help command to Help menu
  • The hotkeys were removed
  • CLI errors now actually close the program instead of making the script persistent
  • The logo is now embedded into the executable
r2:
  • [*:3dgxhmdo]Removed arbitrary 16 images per icon limit
  • Tolerate the absence of AutoHotkey.exe and remove the /iLib temp script
  • Add support for changing the .bin file in the GUI (the selection is also stored in the registry)
  • Actually implement the GUI hotkeys
  • Fix the title bar typo




Lexikos
  • Administrators
  • 9844 posts
  • AutoHotkey Foundation
  • Last active:
  • Joined: 17 Oct 2006
Excellent work. :)

Suggestions:

Change "AHK_L 1.1.01" to "AHK_L v1.1.01" :p

Add UseErrorLevel when invoking AutoHotkey.exe /iLib. Ahk2Exe normally tolerates its absence. Also, delete the temp file after use.

Rename the script files so they don't get "lost" in my Compiler folder, which also has various files for Compile_AHK (and a couple other things). ;) Ahk2Exe_*.ahk perhaps.

Implement an additional option in the GUI:

Posted Image
Uploaded with ImageShack.us

Version info can be pulled from the files, which can be named "Unicode 32-bit.bin" etc. to make things easy. (Or you can omit the version number; I don't really care as long as the filenames can stay the same between releases.) This way I can change the installer so that the choice of binary only affects AutoHotkey.exe; i.e. 64-bit users can more easily compile 32-bit scripts. (Screenshot is from my own incomplete GUI; notice the lack of a Convert button. :lol:)

fincs
  • Moderators
  • 1662 posts
  • Last active:
  • Joined: 05 May 2007
Thanks for your insight :)

However, if multiple *.bin files are to be able to be selected, what would happen to AutoHotkeySC.bin? Would it become a symbolic link to other binaries?

Currently I'm thinking of having AutoHotkeySC_w32.bin, '_a32.bin and '_w64.bin. What do you think of these? (Friendly names would obviously be shown to the user in the GUI).

Lexikos
  • Administrators
  • 9844 posts
  • AutoHotkey Foundation
  • Last active:
  • Joined: 17 Oct 2006

... what would happen to AutoHotkeySC.bin?

Hmm. It should probably be kept and used by default, in case there are any scripts that rely on it. Perhaps it can be a symlink to (or copy of) whichever build was chosen during installation. It might be useful for the GUI to list all bin files, including custom ones the user may have put in the Compiler folder. You could exclude AutoHotkeySC.bin, or put the other bin files in their own subfolder.

Currently I'm thinking of having AutoHotkeySC_w32.bin, '_a32.bin and '_w64.bin. What do you think of these?

That's fine, but I figured it would be simpler to use friendly names for the files. Then again, that might make it more difficult to translate/localize.

Lexikos
  • Administrators
  • 9844 posts
  • AutoHotkey Foundation
  • Last active:
  • Joined: 17 Oct 2006
I thought I'd share some (potentially) interesting facts:

If you compile this script using itself (and you don't use mpress), you can use the resulting exe instead of AutoHotkeySC.bin, since it will simply replace the script resource. However, it won't work if you choose a custom icon, since in that case it adds a resource named ">AHK WITH ICON<" instead of replacing ">AUTOHOTKEY SCRIPT<", and the latter takes precedence. Ahk2Exe could work around this by first removing the ">AUTOHOTKEY SCRIPT<" resource; then Ahk2Exe.exe (plus AutoHotkey.exe if you use function library auto-inclusion) would be all you need to compile a file.

Since there are scripts that rely on Ahk2Exe.exe, I thought that when the time comes to distribute this script with AutoHotkey_L, it would be best to either include it in compiled form or have the installer automatically run the script to compile itself. So I went about measuring the effects it has on the size of the installer. These are the results:
[*:1ygn4gxi]Installer without Ahk2Exe: 2,554 KB
[*:1ygn4gxi]Installer with original Ahk2Exe: 2,591 KB (+37 KB)
[*:1ygn4gxi]Installer with fincs' Ahk2Exe, compiled and compressed: 2,849 KB (+294 KB)
[*:1ygn4gxi]Installer with fincs' Ahk2Exe, compiled but not compressed: 2,559 KB (+5 KB) The reason for this is that the installer is compressed in one solid block, and most of the data of the compiled exe is already present in AutoHotkeySC.bin. If the script is compressed before inclusion in the installer, the data is different and the second layer of compression becomes much less effective.

fincs
  • Moderators
  • 1662 posts
  • Last active:
  • Joined: 05 May 2007
Ok, I just released r2:[*:28stcfft]Removed arbitrary 16 images per icon limit
[*:28stcfft]Tolerate the absence of AutoHotkey.exe and remove the /iLib temp script
[*:28stcfft]Add support for changing the .bin file in the GUI (the selection is also stored in the registry)
[*:28stcfft]Actually implement the GUI hotkeys
[*:28stcfft]Fix the title bar typo:)

Lexikos
  • Administrators
  • 9844 posts
  • AutoHotkey Foundation
  • Last active:
  • Joined: 17 Oct 2006
Very good. I see no reason not to include it in the next AutoHotkey_L release. :)

However, the hotkeys seem rather necessary. Alt+F4 already closes the window, without implementing it as a hotkey. The Convert button already has the Alt+C accelerator, which is typically more visible (on the button itself) than the File menu. Binding F1 to the About box is almost as helpful as binding it to a MsgBox that says "Sorry, there's no help file." (Actually, the whole menu bar seems pretty useless to me.)

Are we trying to improve on Ahk2Exe, or create an exact duplicate of it down to the finest (unnecessary) detail?

Speaking of fine detail, ;) I noticed the "v" is also missing from the <COMPILER:...> comment which is added at the top of the script.

fincs
  • Moderators
  • 1662 posts
  • Last active:
  • Joined: 05 May 2007

Very good. I see no reason not to include it in the next AutoHotkey_L release. :)

Go ahead if you want :)

However, the hotkeys seem rather necessary. (...)

Anyway, it's all carried over from Ahk2Exe, so...

Minor nitpick: did you mean unnecessary?

Actually, the whole menu bar seems pretty useless to me.

It did make sense when we had the Compression menu, but now it's indeed really useless...

Binding F1 to the About box is almost as helpful as binding it to a MsgBox that says "Sorry, there's no help file."

:idea: How about opening the section on Ahk2Exe in AutoHotkey.chm? Speaking of which, it should be updated then...

Are we trying to improve on Ahk2Exe, or create an exact duplicate of it down to the finest (unnecessary) detail?

Both. Some scripts might rely on those hotkeys, I'm not sure...

Speaking of fine detail, ;) I noticed the "v" is also missing from the <COMPILER:...> comment which is added at the top of the script.

:lol:

Lexikos
  • Administrators
  • 9844 posts
  • AutoHotkey Foundation
  • Last active:
  • Joined: 17 Oct 2006

did you mean unnecessary?

Yes. It was getting late...

How about opening the section on Ahk2Exe in AutoHotkey.chm?

That sounds reasonable.

Speaking of which, it should be updated then...

What did you have in mind? I suppose the UTF-8 warning is obsolete, or could be made obsolete.

Some scripts might rely on those hotkeys,

How? They can't send the keystrokes to activate them, since your script uses the keyboard hook. That's actually my main problem with them; if they were standard keyboard accelerators (which are on my todo list) I wouldn't have bothered. Anyway, I think it would be silly to automate the Ahk2Exe GUI.

Anyway, it's all carried over from Ahk2Exe, so...

Hence my rhetorical question about unnecessary detail.

To save cluttering up the Compiler folder, I'm considering including only Ahk2Exe.exe (and readme, if you wish). Would you like to add somewhere a link to this thread/the source code?

Edit: It would be good if the logo image was embedded in the script, at least when it's compiled. I suppose that you could use FileInstall to add the RCDATA resource, then Find/Load/LockResource and GDI+ to load the image. Also, looks like the same image as a gif is 1/3 the size.

fincs
  • Moderators
  • 1662 posts
  • Last active:
  • Joined: 05 May 2007

What did you have in mind? I suppose the UTF-8 warning is obsolete, or could be made obsolete.

I had this in mind:[*:1p2krg52]Remove references to AutoIt3.
[*:1p2krg52]Indeed remove the UTF-8 warning; CP0 is the default encoding in the ANSI build and UTF-8 in the Unicode build (you must be running the uncompiled Ahk2Exe for this).
[*:1p2krg52]Remove references to the compression level & password, other than "Not supported".

How? They can't send the keystrokes to activate them, since your script uses the keyboard hook.

I did not know that, thanks for telling me. Well, I guess I'll remove the hotkeys then, they're doing more harm than good.

EDIT: I've just pushed the changes.

Lexikos
  • Administrators
  • 9844 posts
  • AutoHotkey Foundation
  • Last active:
  • Joined: 17 Oct 2006
D'oh, please see my edit.

I had this in mind:

Sounds good. If you'd like to make the changes and push to your docs repo, that would save me some time. ;)

Btw, I've just tested the script on Win2k. All is well. :)

fincs
  • Moderators
  • 1662 posts
  • Last active:
  • Joined: 05 May 2007

Edit: It would be good if the logo image was embedded in the script, at least when it's compiled. I suppose that you could use FileInstall to add the RCDATA resource, then Find/Load/LockResource and GDI+ to load the image. Also, looks like the same image as a gif is 1/3 the size.

Ok. I will do it tomorrow, it's late here now.

Would you like to add somewhere a link to this thread/the source code?
(...)
Sounds good. If you'd like to make the changes and push to your docs repo, that would save me some time.

I'll do it myself :)

fincs
  • Moderators
  • 1662 posts
  • Last active:
  • Joined: 05 May 2007
Ok, r3 is now here:[*:1zbd95f0]Added missing 'v' to <COMPILER: ...> comment in compiled scripts
[*:1zbd95f0]Added Help command to Help menu
[*:1zbd95f0]The hotkeys were removed
[*:1zbd95f0]CLI errors now actually close the program instead of making the script persistent
[*:1zbd95f0]The logo is now embedded into the executableLexikos, I've just sent you a pull request on the AHK_L documentation.

Lexikos
  • Administrators
  • 9844 posts
  • AutoHotkey Foundation
  • Last active:
  • Joined: 17 Oct 2006
Thanks.

I just noticed the script saves settings to the registry after you compile. The original Ahk2Exe saved settings on exit, which is more ideal IMO. For instance, if I compile a script with a custom icon, then clear the icon (click Default), I don't want the icon to return when I restart the Ahk2Exe script.

fincs
  • Moderators
  • 1662 posts
  • Last active:
  • Joined: 05 May 2007
Done, I've just pushed the changes.