ahk2exe and library includes issue

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Pacheco
Posts: 3
Joined: 16 Jan 2018, 18:44

ahk2exe and library includes issue

16 Jan 2018, 19:01

Hi all,

TL;DR: "new" AHK versions broke LIB folder inclusion when script is compiled but not when running it in script form?

I've been a user of AHK for long years, but recently faced an issue.
I've been using an AHK_L version from back 2015 (1.1.20.01), so I decided to update it to current latest.

Did so, and noticed that recompiling one of my scripts (that I've been running from maybe 8+ years) broke it.
However it runs fine in AHK form. (both using the ANSI executable, Win7)

The script does a lot of things, but the issue seems to be around the following code:

Code: Select all

if (A_Is64Bit())
{
    WinRAR_PATH := RegRead64("HKEY_LOCAL_MACHINE", "SOFTWARE\WinRAR", "exe64")
} else {
    RegRead, WinRAR_PATH, HKEY_LOCAL_MACHINE, SOFTWARE\WinRAR, exe32
}
Now, notice that A_Is64Bit() and RegRead64() are not officially part of AHK, but I got them some years ago from the forums.
I've added them to the attachments for reference (in case it makes a difference).

I have both of them in the lib folder of AHK (as always):
"C:\Program Files\AutoHotkey\Lib"

Also in my script I'm not playing with any form of #include directive...

The script is failing with the following message:
---------------------------
my_script.exe
---------------------------
Error: Call to nonexistent function.

Specifically: A_Is64Bit())

Line#
---> 025: if (A_Is64Bit())

The program will exit.
---------------------------
OK
---------------------------
Again, it was working fine with AHK_L before, and also works fine with the script in ahk.
It only fails when compiled.

I'm using SciTE4AutoHotkey to compile where the compilation command it is running is:
"C:\Program Files\AutoHotkey\SciTE\..\Compiler\Ahk2Exe.exe" /in "D:\Dropbox\AHK\my_script.ahk" /bin "C:\Program Files\AutoHotkey\SciTE\..\Compiler\ANSI 32-bit.bin"

Is this something that changed recently or is known to be an issue? (I couldn't find anything in the 10 mins or so I searched this forum)

[update]
I had a copy of the autohotkey folder before installing the new version, and managed to find that if I revert the "C:\Program Files\AutoHotkey\AutoHotkey.exe" back to the 2015 version and recompile the script, it runs again sucessfully...
Now, that sounds weird as I wouldn't expect the main executable to affect the script compilation (I thought ahk2exe would be independent from the main exe one).
Something changed for sure... maybe I need to do new actions in my script to be compliant with the new AHK versions?
Attachments
RegRead64.ahk
(4.4 KiB) Downloaded 15 times
A_Is64Bit.ahk
(217 Bytes) Downloaded 18 times
Last edited by Pacheco on 16 Jan 2018, 19:42, edited 1 time in total.
Osprey
Posts: 453
Joined: 18 Nov 2017, 05:50

Re: ahk2exe and library includes

16 Jan 2018, 19:17

From the "libraries of functions" entry in the help file:
The script compiler (ahk2exe) also supports library functions. However, it requires that a copy of AutoHotkey.exe exist in the directory above the compiler directory (which is normally the case). If AutoHotkey.exe is absent, the compiler still works but library functions are not automatically included.
You're technically running the compiler from the Compiler subfolder, but maybe the way that you've structured your command is causing a problem (because it's assuming a different working directory). Have you tried doing the following, instead?
"C:\Program Files\AutoHotkey\Compiler\Ahk2Exe.exe" /in "D:\Dropbox\AHK\my_script.ahk" /bin "C:\Program Files\AutoHotkey\Compiler\ANSI 32-bit.bin"

BTW, I'm not sure why the help file mentions "AutoHotkey.exe", since there's no AutoHotkey.exe in recent versions (it comes with AutoHotkeyA32.exe, AutoHotkeyU32.exe and AutoHotkeyU64.exe). Perhaps that's the problem? What happens if you try making a copy of AutoHotkeyA32.exe as AutoHotkey.exe?
Pacheco
Posts: 3
Joined: 16 Jan 2018, 18:44

Re: ahk2exe and library includes issue

16 Jan 2018, 19:27

Thanks for trying to help Osprey :)
Have you tried doing the following, instead?
"C:\Program Files\AutoHotkey\Compiler\Ahk2Exe.exe" /in "D:\Dropbox\AHK\my_script.ahk" /bin "C:\Program Files\AutoHotkey\Compiler\ANSI 32-bit.bin"
That was a good point... but unfortunately it doesn't seem to make a difference here...
BTW, I'm not sure why the help file mentions "AutoHotkey.exe", since there's no AutoHotkey.exe in recent versions (...)
The installer seems to create a copy of "AutoHotkeyA32.exe" as "AutoHotkey.exe" automatically.
Reverting the "AutoHotkey.exe" (without touching the "AutoHotkeyA32.exe") seems to work.
Of course I'm suspecting that I'm then tied somehow to the 2015 version by doing this (but haven't played with it enough to confirm)
Osprey
Posts: 453
Joined: 18 Nov 2017, 05:50

Re: ahk2exe and library includes issue

16 Jan 2018, 19:32

Pacheco wrote:The installer seems to create a copy of "AutoHotkeyA32.exe" as "AutoHotkey.exe" automatically.
Ah, OK. I've only ever downloaded the ZIP version, not the installer version, since I like portability.
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: ahk2exe and library includes issue

17 Jan 2018, 01:42

- I would expect that A_Is64Bit() should be A_Is64Bit. It's a variable, not a function. [EDIT:] I see, apparently it's a custom folder. [EDIT:] I was wondering if maybe older versions of AHK allowed you to include (), but it appears not to be the case.
- Try putting the library file in a folder relative to the compiled exe. In %A_ScriptDir%\Lib\.
- Or try using a relative #Include line in the script.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: downstairs, OrangeCat and 172 guests