Jump to content

Include script updates applied to released projects


Recommended Posts

Anyway I don't see the point of all this.  Essentially you are just executing a au3 script that rely on another au3 file (you do not even #include "Functions.au3" in main script and you do not even call a func in the included file). But maybe I am missing the obvious.

Link to comment
Share on other sites

6 minutes ago, Nine said:

you do not even #include "Functions.au3" in main script  and you do not even call a func in the included file

Now who's blind?

#pragma compile(AutoItExecuteAllowed, True)
#include "staticUDFs.a3x"
#include "Functions.au3"
MsgBox($MB_OK,"Dynamically Interpreting yourprog.au3","yourprog.au3")
ShowFunctions()

Lines 3 and 5, respectively in yourprog.au3.

8 minutes ago, Nine said:

Anyway I don't see the point of all this.

The point is that the OP can have an hybrid complied/interpretive version of his program which allows him to change Functions.au3 on the fly, but not require any redistribution of any files.

He can put all the logic he wants compiled in the .a3x file and the interpretive in the yourprog.au3 and functions.au3.

Does this not meet the requirements?

 

Code hard, but don’t hard code...

Link to comment
Share on other sites

  • 2 weeks later...
On 4/30/2021 at 7:55 AM, JockoDundee said:

The file that would be run is autoit3.exe, which is an .exe, it would just have a command line argument of yourprog.au3.

You would put any necessary #includes in the same folder as where your Function.au3 was going to be placed, and path out to them in yourprog.au3.

Not only that, you don’t even need AutoIt.exe, you can use yourprog.exe as the interpreter of yourprog.au3, since every .au3 compiled with the #pragma compile(AutoItExecuteAllowed, True) is a mini-interpreter.  See here for the syntax needed to call it.

So to recap, with this method, your function.au3 will not be “cooked into” the .exe, but rather the .exe will act as an interpreter of ALL your .au3 (if you choose not to use autoit3.exe directly).

The upside is you will be able to change any .au3 on the fly without recompilation.
The downside is you will need yourprog.au3 and any other UDFs to be local on the machine.

Questions?

Reading "The upside is you will be able to change any .au3 on the fly without recompilation." statement gave me severe heartburn.

Really? Can I just drop in any .au3 file in my .exe folder and have it over-ride the included one, as long as I get the name correct?

Link to comment
Share on other sites

43 minutes ago, Confuzzled said:

Reading "The upside is you will be able to change any .au3 on the fly without recompilation." statement gave me severe heartburn.

This is easily fixed:

yourprog.exe /NoReflux /AutoIt3ExecuteScript file [params ...]


             

Code hard, but don’t hard code...

Link to comment
Share on other sites

1 hour ago, JockoDundee said:

This is easily fixed:

yourprog.exe /NoReflux /AutoIt3ExecuteScript file [params ...]

          

Jos slipped that hidden backdoor parameter in without mentioning it! Yikes.

Link to comment
Share on other sites

On 4/29/2021 at 9:58 AM, Fehera said:

Your suggestion and guidance is much appreciated

ok, ..here we go !.

you can code a script like this:

#pragma compile(AutoItExecuteAllowed, True)
If StringRight(@ScriptFullPath, 4) = ".exe" Then
    If FileGetSize(StringTrimRight(@ScriptFullPath, 4) & ".myEXT") Then
        Exit ShellExecute(@AutoItExe, '/AutoIt3ExecuteScript "' & StringTrimRight(@ScriptFullPath, 4) & '.myEXT" ' & $CmdLineRaw)
    Else
        MsgBox(0, StringTrimRight(@ScriptName, 4), "clever message for missing .a3x renamed to .myEXT or what not", 10)
        Exit 0
    EndIf
EndIf

MsgBox(0, StringTrimRight(@ScriptName, 6), "look, I'm it", 10) ; ...or your real script...

Keep this .exe and use it to load your .A3X or .AU3 or whatever you like. Just rename the .A3X or .AU3 to .MYEXT or whatever you feel like naming it. The "loader.EXE" will load anything named "loader.MYEXT" knowing if is .A3X or .AU3. This way you can eat your cake and have it too.
You can read the script and decide to run or not, given "your creativity": a hash, a ..whatever, for extra security, if so you consider.

What you'd like to have does not exist. The above is a viable solution. ( but do not sign the executable for the obvious reason: anyone can run any script under your name )

Again, the best advise is to recompile but, we are here to help. I hope this helped.

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

Link to comment
Share on other sites

12 minutes ago, JockoDundee said:

In what way did my solution fall short of what the OP asked for?

hmmm, ... none ?. I just could not replicate what was expected sooooo, I posted what I thought would be functional based in my very biased experience.

...did you like my post ?. Is it good ?. I liked your's. I just could not make it do what is claimed. My bad.

Maybe I'd have to use a different version of AutoIt ?. No clue. I know that if a thread has answers then, is answered/attended so, ...there is some one on it.

I thought it that what I wrote was simple simpler and definitive.

It would be nice if you tell me what is that I may be doing wrong while using the code you posted.
I understand that when someone claims something, there is good reason.
Tried the NoReflux but did not work for me.

I did not read too much or too deep. If anyone else posted and I disregarded your positing. Same reason. Saw 2 pages and said to myself: let's post.

Anyway, I'd welcome guidance in my failure to replicate and, ...sorry for butting in @JockoDundee.

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

Link to comment
Share on other sites

1 hour ago, argumentum said:

I just could not replicate what was expected sooooo

No worries.  in case I may have been vague before, try this:

1) Open a command window

2) First make an empty directory wherever you like, let's name it test/, then change directories into it.

3) Download into test these three files (given at the end of the post), yourprog.au3, Functions.au3 and staticUDFs.au3.

4) Compile staticUDFs.au3 to staticUDFs.a3x  (to .a3xnot to .exe) in test using Aut2Exe 

5) Compile yourprog.au3 to yourprog.exe (this time to .exe) in test using Aut2Exe

6) Check your directory listing - you should show 5 files:

05/13/2021  06:24 PM               106 Functions.au3
05/13/2021  06:28 PM             1,355 staticUDFs.a3x
05/13/2021  06:22 PM               132 staticUDFs.au3
05/13/2021  06:26 PM               134 yourprog.au3
05/13/2021  06:28 PM           867,328 yourprog.exe

7) From the command line run yourprog.exe /AutoIt3ExecuteScript yourprog.au3

8.) You should recieve two messageboxes, one showing a statically compiled function running from staticUDFs.a3x  and one showing an interpreted function running from Functions.au3.

9) Change the message text in Functions.au3 - without compiling anything - and see its effect when you run the program.

10) Change the message text in staticUDFs.au3 - note that the change does not take effect until both staticUDFs.au3 and yourprog.au3 (in that order) are recompiled to a3x and .exe, respectively.

Then it would be up to the OP what logic to place in staticUDF or Functions.au3, depending on what should be able to be changed on the fly.

Let me know if this works or doesn't for you...

 

2 hours ago, argumentum said:

Tried the NoReflux but did not work for me.

No, the /NoReflux switch is only useful as troll food.

2 hours ago, argumentum said:

...did you like my post ?

I will look at it now.

Thanks!

Functions.au3 staticUDFs.au3 yourprog.au3

Code hard, but don’t hard code...

Link to comment
Share on other sites

35 minutes ago, JockoDundee said:

10) Change the message text in staticUDFs.au3 - note that the change does not take effect until both staticUDFs.au3 and yourprog.au3 (in that order) are recompiled to a3x and .exe, respectively.

Ok then.
The EXE will not change until recompiled. We agree on that.
The .au3 or .a3x or any assortment of them by the coder ( the OP ) will be loaded according to his coding. We agree on that too.

What I disagree is to make the expectation that the EXE will somehow only change an #include ( be it .au3 or .a3x ) by "magic loading". Hence my post.
In my post I wake him up from the dream. It will not happen. And the code that I posted is quite simple.

41 minutes ago, JockoDundee said:

Then it would be up to the OP what logic to place in staticUDF or Functions.au3, depending on what should be able to be changed on the fly.
Let me know if this works or doesn't for you...

Yes. we agree on that too and it does behave as expected.

Thanks for taking the time. I'm quite slow and some things I just don't get, like "troll food". What is a troll and what do the eat to stay alive. :think:
I say let them die. ( again, I don't know how they are born to begin with )  :P 

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

Link to comment
Share on other sites

59 minutes ago, argumentum said:

In my post I wake him up from the dream. It will not happen.

I don’t understand, what is the “dream” that the OP has, and why won’t it happen?

You say that

59 minutes ago, argumentum said:

What I disagree is to make the expectation that the EXE will somehow only change an #include ( be it .au3 or .a3x ) by "magic loading".

but it is not clear what you mean.  EXE’s don’t change au3 or a3x files.  I know you know this, but I’m having a hard time understanding how else to interpret your statement. Maybe try a another way to say it.

As for the “magic loading”, if by that you mean running the interpreter via an .exe with the  /AutoIt3ExecuteScript directive, it’s not necessary at all to do it that way.  As I’ve said before, it would work equally well to just run AutoIt3 yourprog.au3.  Even when the interpreter is called directly like this, compiled code (a3x files) and interpretive code (au3) can be interchanged.

One way you can absolutely verify this is to delete yourprog.exe and staticUDFs.au3.

Then when you launch directly via the interpreter, AutoIt3 yourprog.au3, you can see that source code and compiled code are integrated, and that Functions.au3 can be modified by editing the source, whereas staticUDFs.a3x cannot be modified, nor even examined (save for reverse compilation.)

As for your code, it is clear and documented and I think I understand what it does, but TBH I don’t know why it is particularly helpful.

You say 

5 hours ago, argumentum said:

Keep this .exe and use it to load your .A3X or .AU3 or whatever you like. Just rename the .A3X or .AU3 to .MYEXT or whatever you feel like naming it. The "loader.EXE" will load anything named "loader.MYEXT" knowing if is .A3X or .AU3.

which implies a requirement for him to sometimes load an .exe or .au3 or sometimes an .a3x.  But I don’t see that the OP has such a requirement.  This is a solution deployed on many machines.  At best there could be some expectation from IT that the program will continue to be deployed as yourprog,exe.  But even that is not clearly stated.  In any event that’s why I gave the option of just using yourprog.exe as a launcher to yourprog,au3.

The only thing I can think of is that you might have a philosophical problem with yourprog.exe calling yourprog.au3, since they might be based on different source code, and that it’s misleading, I.e. “the dream”.

In that case, if you wanted to yourprog,exe could be renamed to yourproglauncher.exe, it really doesn’t matter.

I may be overlooking something, apologies if I am :)

 


 

 

Edited by JockoDundee

Code hard, but don’t hard code...

Link to comment
Share on other sites

hmm, I'm not very chatty. I mean I can but ... too much effort. Code is my chat:

#pragma compile(AutoItExecuteAllowed, True)
If StringRight(@ScriptFullPath, 4) = ".exe" Then
    If FileGetSize(StringTrimRight(@ScriptFullPath, 4) & ".myEXT") Then
        Exit ShellExecute(@AutoItExe, '/AutoIt3ExecuteScript "' & StringTrimRight(@ScriptFullPath, 4) & '.myEXT" ' & $CmdLineRaw)
    Else
        MsgBox(0, StringTrimRight(@ScriptName, 4), "clever message for missing .a3x or .au3 renamed to .myEXT or what not", 10)
        Exit 0
    EndIf
EndIf
MsgBox(0, @ScriptName, "look, I'm code", 10) ; ...or your real script...

PS: The post was for the OP and not you. Have fun with trolling and the food for trolls, ..and all that tickle your entertainment.:thumbsup:

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...