AutoHotkey / AutoHotkeyDocs

Documentation for AutoHotkey
https://autohotkey.com/
367 stars 715 forks source link

compile_chm.ahk for v2 written in v1 #696

Closed kiwichick888 closed 1 day ago

kiwichick888 commented 1 month ago

I've just downloaded the v2 docs so I can use compile.ahk to create a help file with the old sidebar. But why is compile.ahk for the v2 docs written in v1? How am I supposed to run if it v1 isn't installed?

Ragnar-F commented 1 month ago

But why is compile.ahk for the v2 docs written in v1?

This is because compile_chm.ahk was created when there was no v2. It has not yet been updated to v2 because some release procedures assume it is v1 and doing so might break them.

Currently I know of only two procedures that run this script:

If @Lexikos agrees, I can update all non-v2 helper scripts (compile_chm.ahk and check_data.ahk) to v2.

Related: Problems related to v2 docs compile_chm.ahk

kiwichick888 commented 1 month ago

If @Lexikos agrees, I can update all non-v2 helper scripts (compile_chm.ahk and check_data.ahk) to v2.

Let's hope he does because it would be great if you could update the scripts.

Lexikos commented 3 weeks ago

That's fine.

The release script specifies a v1 32-bit exe because compile_chm.ahk currently uses the ScriptControl COM component. If the updated script still uses that, the #Requires directive should be used to provide a hint to the launcher, like so:

#Requires AutoHotkey v2 ; prefer 32-bit
Ragnar-F commented 3 weeks ago

I've updated the scripts to v2.

kiwichick888 commented 1 week ago

I've updated the scripts to v2.

I've downloaded the latest version but it doesn't work for me. This is the error I get when I run it.

2024-08-27_142907
Ragnar-F commented 1 week ago

compile_chm.ahk must be run with the 32-bit version of AutoHotkey v2 (AutoHotkey32.exe). #Requires actually makes sure it is used automatically. This file may be missing from your installation folder.

What does MsgBox A_PtrSize report? 4 (32-bit) or 8 (64-bit)?

What happens if you replace #Requires AutoHotkey v2 ; prefer 32-bit with #Requires AutoHotkey v2 32-bit?

kiwichick888 commented 1 week ago

compile_chm.ahk must be run with the 32-bit version of AutoHotkey v2 (AutoHotkey32.exe). #Requires actually makes sure it is used automatically. This file may be missing from your installation folder.

The 32-bit file is not missing from my installation folder.

What does MsgBox A_PtrSize report? 4 (32-bit) or 8 (64-bit)?

It says 8, which it should because I use the 64-bit version of AHK.

What happens if you replace #Requires AutoHotkey v2 ; prefer 32-bit with #Requires AutoHotkey v2 32-bit?

It says the following, which of course it will say because I use the 64-bit version of AHK: "Error: This script requires AutoHotkey v2 32-bit.

Current interpreter: AutoHotkey v2.0.18 64-bit C:\PortableApps\AutoHotkey\AutoHotkey64.exe"

What is the difference between using AHK 32-bit and 64-bit? Am I better off just using the 32-bit version by default? Or is there code I can add to compile_chm.ahk to tell it to use the 32-bit interpreter?

Ragnar-F commented 1 week ago

This depends on how you run the script.

If you installed AutoHotkey normally, then double-clicking the script icon in Explorer or using Run PathToScript should run the script. The launcher will handle this automatically. If it doesn't run, check the launcher settings in the Dash.

If you are running the script from an editor, for example to debug it, check the corresponding launch settings. If you want to use AutoHotkey's launcher to run a script, compile UX\launcher.ahk and use its EXE path. At least that's how I do it in my VSCode, no idea if there is a better solution. The comments in launcher.ahk suggested it that way.

In the end, the script has to be run with AutoHotkey32.exe - either manually or automatically using the launcher. ComObject("ScriptControl") requires this.

What is the difference between using AHK 32-bit and 64-bit? Am I better off just using the 32-bit version by default?

AHK 32-bit only exists because some old APIs like ScriptControl still need 32-bit. If you are not using them, AHK 64-bit is always recommended.

Or is there code I can add to compile_chm.ahk to tell it to use the 32-bit interpreter?

Yes, #Requires, which is already used in the script. The "prefer" comment is recognized by the launcher.

kiwichick888 commented 1 week ago

If you installed AutoHotkey normally

I use the portable verison but both versions of the exe are in the same folder.

The "prefer" comment is recognized by the launcher.

So why is #Requires AutoHotkey v2 32-bit not working?

Ragnar-F commented 1 week ago

So why is #Requires AutoHotkey v2 32-bit not working?

#Requires AutoHotkey v2 32-bit works. It tells you to use the 32-bit version of AutoHotkey v2 to run the script. You will not see the error message if you have installed AutoHotkey v2 normally.

If you tell me how you run the script, I might be able to help you.

kiwichick888 commented 1 week ago

if you have installed AutoHotkey v2 normally.

As already stated, I use the portable (zip) version so, no, that isn't installed 'normally'. Seeing as AutoHotkey provides a portable version, it's disappointing that it obviously affects the way some scripts work.

If you tell me how you run the script, I might be able to help you.

I double-click compile_chm.ahk.

Ragnar-F commented 3 days ago

I assumed you were familiar with the basics of command line usage. This is obviously not the case if you can't figure it out for yourself.

Based on your information, the easiest thing to do would be to create a new script that runs compile_chm.ahk with the correct interpreter. For example:

#Requires AutoHotkey v2
interpreter := "C:\PortableApps\AutoHotkey\AutoHotkey32.exe"
script := "C:\path\to\compile_chm.ahk"
Run Format('"{1}" "{2}"', interpreter, script)

There are other similar methods, e.g. via batch, but you can find plenty of help on the Internet.

kiwichick888 commented 1 day ago

I assumed you were familiar with the basics of command line usage. This is obviously not the case if you can't figure it out for yourself.

Based on your information, the easiest thing to do would be to create a new script that runs compile_chm.ahk with the correct interpreter. For example:

#Requires AutoHotkey v2
interpreter := "C:\PortableApps\AutoHotkey\AutoHotkey32.exe"
script := "C:\path\to\compile_chm.ahk"
Run Format('"{1}" "{2}"', interpreter, script)

There are other similar methods, e.g. via batch, but you can find plenty of help on the Internet.

No, I don't use command line. Thank you for giving me the code to add to compile_chm.ahk. It's working now 🙂