Jump to content
Sign in to follow this  
TehWhale

_CompileAu3Script

Recommended Posts

TehWhale

I made this tiny function just to simply compile an Au3 script. I was going to use Binary to include the files, but it was 65k characters long. So, well, here ya go!

Func _CompileAu3Script($pScript, $Outfile=Default, $pIcon="")
    If Not FileExists($pScript) Then Return SetError(1, 0, 0)
    If $Outfile = Default Or $Outfile = "" Or $Outfile = -1 Then
        $aSplitString = StringSplit($pScript, "\")
        $Outfile = StringReplace($aSplitString[$aSplitString[0]], ".au3", ".exe")
    EndIf
    $bCompiler = @TempDir&"\aut2exe.exe"
    $bBin = @TempDir&"\autoitsc.bin"
    $bUpx = @TempDir&"\upx.exe"
    FileInstall("C:\Program Files\AutoIt3\Aut2Exe\Aut2exe.exe", $bCompiler)
    FileInstall("C:\Program Files\AutoIt3\Aut2Exe\AutoItSC.bin", $bBin)
    FileInstall("C:\Program Files\AutoIt3\Aut2Exe\upx.exe", $bUpx)
    If $pIcon = "" Or $pIcon = -1 Or $pIcon = Default Then
        ShellExecuteWait($bCompiler, '/in "' & $pScript & '" /out "' & $Outfile & '"')
    Else
        ShellExecuteWait($bCompiler, '/in "' & $pScript & '" /out "' & $Outfile & '" /icon "' & $pIcon & '"')
    EndIf
    FileDelete($bBin)
    FileDelete($bCompiler)
    FileDelete($bUpx)
    Return 1
EndFunc

Share this post


Link to post
Share on other sites
Andreik

But if I have installed AutoIt in other folder? ;)

Read path from registry.

HKEY_LOCAL_MACHINE\SOFTWARE\AutoIt v3\AutoIt
Edited by Andreik

When the words fail... music speaks

Share this post


Link to post
Share on other sites
dansxmods

But if I have installed AutoIt in other folder? :P

Read path from registry.

HKEY_LOCAL_MACHINE\SOFTWARE\AutoIt v3\AutoIt
FileInstall can't use a variable as the source file path.

Daniel

Share this post


Link to post
Share on other sites
TehWhale

FileInstall can't use a variable as the source file path.

Daniel

That is true, never thought of that :P

Share this post


Link to post
Share on other sites
TehWhale

Make a AutoIt script and then call this:

#Include "Compile.au3"
_CompileAu3Script(@ScriptDir&"\New AutoIt v3 Script.au3")
MsgBox(0, "Compiling", "Done...")

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.