Jump to content

_CompileAu3Script


TehWhale
 Share

Recommended Posts

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
Link to comment
Share on other sites

  • 1 month later...
  • 4 weeks later...

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...