Sign in to follow this  
Followers 0
The Kandie Man

External Execute UDF Functions

3 posts in this topic

#1 ·  Posted (edited)

This is a UDF i wrote. I thought this could be quite handy. It contains three functions. One function is used to run an external au3 script, adding a sort of psuedo "multithreading" feature to compiled autoit scripts. Keep in mind it isn't actually multithreading, but simply one way to get around the multithreading limitation in autoit.

The next function lets you run a single function from within an external script.

The last function is a special function that i wrote that creates an autoit script host. When the function is called it installs an autoit executable on the target machine and associates the .extau3 file extension with itself. As a result the target machine can now run uncompiled au3 scripts with the .extau3 file extension as well as .a3x files with the .extau3 extension.

[EDIT]

Another way of looking at this is it essentially allows you to execute scripts like external link libraries. My one function allows you to call a function within a script, much like the way you would call a function inside a dll.

In addition, you can simply have the entire script executed. This makes it easy for you to leave some parts of the program open source. For example, you could have a function that places folders or files in a certain place and the user could then go into the script itself and modify it. Then when they run the compiled au3 script that isn't open source, it will be able to run the user-modified script like a custom dll.

The last function is a function all of its own. When used with the source provided in the source box below, it will allow you to create an autoit script host on the target users computer. This will cause autoit to run essentially like the microsoft script host that allows the executation of vbs scripts. The full compilation of autoit scripts would therefore not be required in order for the target user to execute autoit scripts without autoit installed. In addition, you could simply send the target machine .a3x files(compiled source files that only contain a compiled version of the source and are therefore extremely small, but not readable). Please note that the extension for these files is .extau3 I did this to prevent conflicts with computers that already had autoit installed.

The following code is what i used to create an autoit script host with my _FileAU3Associate function:

#NoTrayIcon
#include "ExternalExecute.au3"

If @AutoItExe = @ProgramFilesDir & "\AutoItExternal\AutoItExt.exe" Then
    _FileAU3Associate()
Else
    dim $answer 

    $answer = MsgBox(36,"Install?","This will install an autoit executable on your computer and associate the extension .extau3 with it.  This computer would then be able to run uncompiled .au3 files with the .extau3 extension was well as .a3x files with the .extau3 extension." & @CRLF & @CRLF & "Installation is done to your program files directory and consists of only one 190KB executable. " & @CRLF & @CRLF & "You may uninstall the program at any time by going to Program Files\AutoItExternal\ and running AutoItExt.exe." & @CRLF & @CRLF & "Do you want to install this AutoIt script interpreter?")
    Select
        Case $answer  = 6 ;Yes
            _FileAU3Associate()
            MsgBox(64,"Installed","Autoit Script Interpreter was successfully installed." & @CRLF & @CRLF & "You may now run .extau3 files.",5)
    Case $answer  = 7 ;No
        Exit
    EndSelect

Endif

This the first version, please report any bugs that you may encounter as well as any questions you may have.

ExternalExecute.au3

Edited by The Kandie Man

"So man has sown the wind and reaped the world. Perhaps in the next few hours there will no remembrance of the past and no hope for the future that might have been." & _"All the works of man will be consumed in the great fire after which he was created." & _"And if there is a future for man, insensitive as he is, proud and defiant in his pursuit of power, let him resolve to live it lovingly, for he knows well how to do so." & _"Then he may say once more, 'Truly the light is sweet, and what a pleasant thing it is for the eyes to see the sun.'" - The Day the Earth Caught Fire

Share this post


Link to post
Share on other sites



No, haven't done a whole lot of work on it since i wrote it. If there is more interest in it, I would always be willing to re-write some stuff or add user requested functions. It seems there have been significantly more downloads since i last checked. I may do a re-write if it continues. I was shocked that nobody really took much notice when i first posted this, but i suspect that most people really didn't know what this did or how it could be effectively used in their scripts.

-The Kandie Man


"So man has sown the wind and reaped the world. Perhaps in the next few hours there will no remembrance of the past and no hope for the future that might have been." & _"All the works of man will be consumed in the great fire after which he was created." & _"And if there is a future for man, insensitive as he is, proud and defiant in his pursuit of power, let him resolve to live it lovingly, for he knows well how to do so." & _"Then he may say once more, 'Truly the light is sweet, and what a pleasant thing it is for the eyes to see the sun.'" - The Day the Earth Caught Fire

Share this post


Link to post
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
Sign in to follow this  
Followers 0