Open jmbeach opened 3 months ago
Hi! Thanks for the kind words. #Include
is a directive and as such isn't part of the normal execution flow. You can't use conditions https://phil294.github.io/AHK_X11/#h_Include.htm and in the mainstream windows ahk 1.1. docs (which we don't aim to implement, but it's 100% backwards compatible) it even says here https://www.autohotkey.com/docs/v1/lib/_Include.htm
SetWorkingDir has no effect on #Include
which is 1:1 the title of this very issue :-)
So it seems to me everything is (not) working exactly as intended.
I guess you could use %A_ScriptDir%
as part of the #Include
statement, but I don't think it will work. That's something that should be fixed, if this is the case, as the docs claim it works
Ah, haha. I didn't catch that in the docs about #Include
. That's awesome.
In that case, yes, what I'm trying to solve is being able to use %A_ScriptDir%
in the #Include
statement. That would solve my problem.
If I try to use %A_ScriptDir
in my #Include
statement like this:
#Include %A_ScriptDir%/src/layout-manager.ahk
I get the error:
Error opening file with mode 'r':'/home/jared/code/github/jmbeach/autohotkey-x11-scripts/%A_ScriptDir%/src/layout-manager.ahk':No such file or directory.
Line content was: '#Include %A_ScriptDir%/src/layout-manager.ahk'
The program will exit.
Yeah pretty much as expected. Unsure when I'll fix that, so for now it seems you will have to specify full paths. Or you just cd into the actual directory before running. Or perhaps, you wrap the script into another script (bash, python, even another ahk_x11 script should do it) which sets the working dir to the script dir and then runs the actual script, whose includes will then work as expected.
Ah yeah, good idea. I'll just do that for now. Thanks!
Hello, thanks so much for your work on this project! I've just started using it and it's already invaluable to me.
I've noticed that even though I run
SetWorkingDir %A_ScriptDir%
at the top of my script,#Include
commands are being ran from the location that I started the script and not the location that the script is in.Here is the file in question. If I add
MsgBox
's to see the values of%A_ScriptDir%
and%A_WorkingDir%
before the#Include
's:The MsgBox's never pop up and the script fails saying
Error opening file with mode 'r': '/home/jared/src/layout-manager.ahk': No such file or directory.
If I comment out the
#Include
lines to see theMsgBox
's, the values actually look correct. They both popup with/home/jared/code/github/jmbeach/autohotkey-x11-scripts
even when I run from/home/jared
.