Sign in to follow this  
Followers 0
GaryFrost

compile multiple au3 scripts

1 post in this topic

created this for projects that will require multiple exes created, helped me, hope it will help others.

compile and place in the aut2exe folder, perl script for password generator is listed at the end

#include <Process.au3>

AutoItSetOption ("MustDeclareVars",1)

AdlibEnable ( "ADLIBSection" )

Dim $iconvar, $icondir

Dim $sourcedir, $sourcevar, $sourcefilename

Dim $destdir, $destvar

Dim $s_message

Dim $inifile, $P_exe, $passwd, $singlefile

Dim $SourceFileArray[1],$SourceExePath[1],$SourceIcon[1]

if ($CmdLine[0] = 1 and ($CmdLine[1] = '/?' or $CmdLine[1] = '/h')) then

Help_Message ( )

Exit

elseif $CmdLine[0] > 0 then

$s_message = @LF & @LF & " Source File: " & $sourcevar & @LF & @LF & " Destination File: " & $destvar & @LF & @LF & " Icon File: " & $iconvar

SplashTextOn ( "Compile AutoIt v3",$s_message,900,200,100,300,22,"Courier New Bold",9)

WinWait ( "Compile AutoIt v3" )

WinActivate ( "Compile AutoIt v3" )

$inifile = "C:\Program Files\AutoIt3\Aut2Exe\compile.ini"

ReadIniDefaults ($inifile, $sourcedir, $destdir, $icondir, $P_exe )

#cs

----------------------------------------------------------------------

generate random password

----------------------------------------------------------------------

#ce

$passwd = GetPassword ( $P_exe )

RunWait ( $P_exe )

if $CmdLine[0] = 1 and StringInStr($CmdLine[1],".ini") then

Process_Ini_File ( $s_message, $sourcevar, $SourceFileArray, $SourceExePath, $SourceIcon, $sourcevar, $destvar, $iconvar, $icondir)

elseIf $CmdLine[0] >= 2 then

if StringInStr ($CmdLine[1], ".au3") then

$sourcevar = '"' & $CmdLine[1] & '"'

if StringInStr($CmdLine[2], ".exe") then

$destvar = '"' & $CmdLine[2] & '"'

if $CmdLine[0] = 3 and StringInStr($CmdLine[3],".ico") then

$iconvar = '"' & $icondir & $CmdLine[3] & '"'

else

$iconvar = '"' & $icondir & 'AutoIt_32x32x256.ico"'

endif

else

Help_Message ( )

Exit

endif

else

Help_Message ( )

Exit

endif

CompileFile ($s_message, $sourcevar, $destvar, $iconvar, $passwd)

else

Help_Message ( )

Exit

endif

Exit

endif

$s_message = @LF & @LF & " Source File: " & $sourcevar & @LF & @LF & " Destination File: " & $destvar & @LF & @LF & " Icon File: " & $iconvar

SplashTextOn ( "Compile AutoIt v3",$s_message,900,200,100,300,22,"Courier New Bold",9)

WinWait ( "Compile AutoIt v3" )

WinActivate ( "Compile AutoIt v3" )

$inifile = "C:\Program Files\AutoIt3\Aut2Exe\compile.ini"

ReadIniDefaults ($inifile, $sourcedir, $destdir, $icondir, $P_exe )

#cs

----------------------------------------------------------------------

generate random password

----------------------------------------------------------------------

#ce

$passwd = GetPassword ( $P_exe )

RunWait ( $P_exe )

SelectSource ( $sourcevar, $sourcefilename, $singlefile, $sourcedir )

if $singlefile = 1 then

SelectDest ( $sourcefilename, $s_message, $destvar, $destdir, $sourcevar, $destvar, $iconvar )

SelectIcon ( $sourcefilename, $iconvar, $icondir, $sourcevar, $destvar)

SplashTextOn ( "Compile AutoIt v3",$s_message,900,200,100,300,20,"Courier New Bold",9)

CompileFile ($s_message, $sourcevar, $destvar, $iconvar, $passwd)

else

SplashTextOn ( "Compile AutoIt v3",$s_message,900,200,100,300,20,"Courier New Bold",9)

Process_Ini_File ( $s_message, $sourcevar, $SourceFileArray, $SourceExePath, $SourceIcon, $sourcevar, $destvar, $iconvar, $icondir)

endif

WriteIniDefaults($inifile, $sourcedir, $destdir, $icondir, $P_exe )

SplashOff ()

Exit

#cs

====================================================================================================

============

Custom Functions

====================================================================================================

============

#ce

#cs

----------------------------------------------------------------------

select a single file or ini file

----------------------------------------------------------------------

#ce

Func SelectSource ( ByRef $sourcevar, ByRef $sourcefilename, ByRef $singlefile, ByRef $sourcedir )

Dim $o_message,$message,$rows,$output

Dim $myArray[80],$r

$message = "Choose AutoIt Source File"

$sourcevar = FileOpenDialog($message, $sourcedir, "AutoIt V3 (*.au3;*.ini)", 1 )

If @error Then

MsgBox(8208,"","No Source File chosen")

Exit

Else

$output = ''

$myarray = StringSplit ( $sourcevar, "\" )

$rows = UBound($myArray)

For $r = 1 to UBound($myArray) - 2

$output = $output & $myArray[$r] & "\"

Next

$sourcefilename = $myArray[uBound($myArray) - 1]

$myarray = StringSplit ( $sourcefilename, "." )

$sourcefilename = $myArray[1]

if StringInStr ($myArray[2],"au3") then

$singlefile = 1

else

$singlefile = 0

endif

$sourcedir = $output

$sourcevar = StringReplace($sourcevar, "|", @CRLF)

if $singlefile Then

$sourcevar = '"' & $sourcevar & '"';

endif

EndIf

$o_message = $s_message

$s_message = @LF & @LF & " Source File: " & $sourcevar & @LF & @LF & " Destination File: " & $destvar & @LF & @LF & " Icon File: " & $iconvar

ControlSetText ( "Compile AutoIt v3", $o_message, "Static1", $s_message )

Endfunc

#cs

----------------------------------------------------------------------

If single file selected for compile, need to select destination for exe

----------------------------------------------------------------------

#ce

Func SelectDest ($sourcefilename, ByRef $s_message, ByRef $destvar, ByRef $destdir, $sourcevar, ByRef $destvar, $iconvar )

Dim $o_message,$message,$rows,$output

Dim $myArray[80],$r

$message = "Choose Destination File Name for (" & $sourcefilename & ")"

$destvar = FileOpenDialog($message, $destdir, "AutoIt V3 (*.exe)" )

If @error Then

MsgBox(4096,"","No Destination File chosen")

Exit

Else

$output = ''

$myarray = StringSplit ( $destvar, "\" )

$rows = UBound($myArray)

For $r = 1 to UBound($myArray) - 2

$output = $output & $myArray[$r] & "\"

Next

$destdir = $output

$destvar = StringReplace($destvar, "|", @CRLF)

if StringInStr($destvar, ".exe") then

$destvar = '"' & $destvar & '"';

else

$destvar = '"' & $destvar & '.exe"';

endif

EndIf

$o_message = $s_message

$s_message = @LF & @LF & " Source File: " & $sourcevar & @LF & @LF & " Destination File: " & $destvar & @LF & @LF & " Icon File: " & $iconvar

ControlSetText ( "Compile AutoIt v3", $o_message, "Static1", $s_message )

Endfunc

#cs

----------------------------------------------------------------------

If single file selected for compile, need to select icon

----------------------------------------------------------------------

#ce

Func SelectIcon ( $sourcefilename, ByRef $iconvar, ByRef $icondir, $sourcevar, $destvar)

Dim $o_message,$message,$rows,$output

Dim $myArray[80],$r

$message = "Choose Icon File Name for (" & $sourcefilename & ")"

$iconvar = FileOpenDialog($message, $icondir, "Icons (*.ico)" )

If @error Then

; no icon selected set default icon

$iconvar = '"' & $icondir & 'AutoIt_32x32x256.ico"'

else

$output = ''

$myarray = StringSplit ( $iconvar, "\" )

$rows = UBound($myArray)

For $r = 1 to UBound($myArray) - 2

$output = $output & $myArray[$r] & "\"

Next

$icondir = $output

$iconvar = StringReplace($iconvar, "|", @CRLF)

$iconvar = '"' & $iconvar & '"';

EndIf

$o_message = $s_message

$s_message = @LF & @LF & " Source File: " & $sourcevar & @LF & @LF & " Destination File: " & $destvar & @LF & @LF & " Icon File: " & $iconvar

ControlSetText ( "Compile AutoIt v3", $o_message, "Static1", $s_message )

Endfunc

#cs

----------------------------------------------------------------------

Auto generate password

----------------------------------------------------------------------

#ce

Func GetPassword ( ByRef $P_exe )

Dim $message, $passwd

if $P_exe = '' Then

$message = "Choose Password Generator"

$P_exe = FileOpenDialog($message, '\\aedcgw03\f$\Projects\Library\App-Installs\code\', "Exe (*.exe)" )

If @error Then

MsgBox(4096,"","No Password Generator chosen")

Exit

Else

$P_exe = StringReplace($P_exe, "|", @CRLF)

EndIf

EndIf

$passwd = ClipGet()

return $passwd

Endfunc

#cs

----------------------------------------------------------------------

Compile each file and display on splash

----------------------------------------------------------------------

#ce

Func CompileFile (ByRef $s_message, $sourcevar, $destvar, $iconvar, $passwd)

Dim $A_exe, $o_message, $x

$A_exe = '"C:\Program Files\AutoIt3\Aut2Exe\Aut2exe.exe"'

$o_message = $s_message

$s_message = @LF & @LF & " Source File: " & $sourcevar & @LF & @LF & " Destination File: " & $destvar & @LF & @LF & " Icon File: " & $iconvar & @LF & @LF & "Compiling"

ControlSetText ( "Compile AutoIt v3", $o_message, "Static1", $s_message )

Run ($A_exe & ' /in ' & $sourcevar & ' /out ' & $destvar & ' /icon ' & $iconvar & ' /pass ' & $passwd)

$x = 0

While ProcessExists ( "Aut2exe.exe" )

$o_message = $s_message

if $x = 0 then

$x = 1

$s_message = @LF & @LF & " Source File: " & $sourcevar & @LF & @LF & " Destination File: " & $destvar & @LF & @LF & " Icon File: " & $iconvar & @LF & @LF & " Compiling |"

elseif $x = 1 then

$x = 2

$s_message = @LF & @LF & " Source File: " & $sourcevar & @LF & @LF & " Destination File: " & $destvar & @LF & @LF & " Icon File: " & $iconvar & @LF & @LF & " Compiling /"

elseif $x = 2 then

$x = 3

$s_message = @LF & @LF & " Source File: " & $sourcevar & @LF & @LF & " Destination File: " & $destvar & @LF & @LF & " Icon File: " & $iconvar & @LF & @LF & " Compiling -"

elseif $x = 3 then

$x = 0

$s_message = @LF & @LF & " Source File: " & $sourcevar & @LF & @LF & " Destination File: " & $destvar & @LF & @LF & " Icon File: " & $iconvar & @LF & @LF & " Compiling \"

endif

ControlSetText ( "Compile AutoIt v3", $o_message, "Static1", $s_message )

Sleep ( 500 )

Wend

Endfunc

#cs

----------------------------------------------------------------------

read/write ini defaults

----------------------------------------------------------------------

#ce

Func ReadIniDefaults ($inifile, ByRef $sourcedir, ByRef $destdir, ByRef $icondir, ByRef $P_exe )

$sourcedir = IniRead ( $inifile, "source", "dir", "." )

$destdir = IniRead ( $inifile, "dest", "dir", "..\exes\" )

$icondir = IniRead ( $inifile, "icon", "dir", "C:\Program Files\AutoIt3\Aut2Exe\Icons\" )

$P_exe = IniRead ( $inifile, "pgen", "exe", "" )

EndFunc

Func WriteIniDefaults($inifile, $sourcedir, $destdir, $icondir, $P_exe )

IniWrite ( $inifile, "source", "dir", $sourcedir )

IniWrite ( $inifile, "dest", "dir", $destdir )

IniWrite ( $inifile, "icon", "dir", $icondir )

IniWrite ( $inifile, "pgen", "exe", $P_exe )

Endfunc

#cs

----------------------------------------------------------------------

read in the names of files and paths for exes

----------------------------------------------------------------------

#ce

Func ReadInData ($inifile, ByRef $SourceFileArray, ByRef $SourceExePath, ByRef $SourceIcon )

Dim $num,$X

$num = IniRead ( $inifile, "files", "num", 0 )

if $num = 0 then

$SourceFileArray = 0

$SourceIcon = 0

$SourceExePath = 0

else

Dim $SourceFileArray[$num]

Dim $SourceIcon[$num]

Dim $SourceExePath[$num]

endif

For $X = 0 to $num - 1

$SourceFileArray[$X] = IniRead ( $inifile, "files", $X + 1, "" )

$SourceExePath[$X] = IniRead ( $inifile, "files", "exe" & $X + 1,"" )

$SourceIcon[$X] = IniRead ( $inifile, "files", "icon" & $X + 1,"AutoIt_32x32x256.ico" )

next

Endfunc

Func Process_Ini_File ( ByRef $s_message, ByRef $sourcevar, ByRef $SourceFileArray, ByRef $SourceExePath, ByRef $SourceIcon, ByRef $sourcevar, ByRef $destvar, ByRef $iconvar, $icondir)

Dim $S,$E

SplashTextOn ( "Compile AutoIt v3",$s_message,900,200,100,300,20,"Courier New Bold",9)

ReadInData ($sourcevar, $SourceFileArray, $SourceExePath, $SourceIcon)

if IsArray ( $SourceFileArray ) then

For $S = 0 to UBound($SourceFileArray) - 1

$sourcevar = '"' & $sourcedir & $SourceFileArray[$S] & '"'

$destvar = '"' & $SourceExePath[$S] & '"'

$iconvar = '"' & $icondir & $SourceIcon[$S] & '"'

CompileFile ($s_message, $sourcevar, $destvar, $iconvar, $passwd)

next

endif

endfunc

Func Help_Message ( )

Dim $s_message

$s_message = "This program will compile a single file or Multiple files" & @LF & @LF

$s_message = $s_message & "To Compile a single file just select the source (au3)" & @LF

$s_message = $s_message & "and destination file (exe), icon optional." & @LF & @LF

$s_message = $s_message & "To Compile multiple files for a project an ini file is" & @LF

$s_message = $s_message & "needed. Example of ini file" & @LF

$s_message = $s_message & "[files]" & @LF

$s_message = $s_message & "num=3" & @LF

$s_message = $s_message & "1=IESetRunOnce.au3" & @LF

$s_message = $s_message & "2=MoveFile.au3" & @LF

$s_message = $s_message & "3=AEDC_Site_Certificate.au3" & @LF

$s_message = $s_message & "exe1=G:\Projects\Packages\InternetExplorer\Certificates\source\IEClearRunOnce.exe" & @LF

$s_message = $s_message & "exe2=G:\Projects\Packages\InternetExplorer\Certificates\source\MoveFile.exe" & @LF

$s_message = $s_message & "exe3=G:\Projects\Packages\InternetExplorer\Certificates\exes\AEDC_Site_Certificate.exe" & @LF

$s_message = $s_message & "icon1=Certificate.ico" & @LF & @LF

$s_message = $s_message & "Optionial is an icon for each file, the icon is presented by " & @LF

$s_message = $s_message & "icon1=icon.ico" & @LF

$s_message = $s_message & "icon2=icon.ico" & @LF

$s_message = $s_message & "The number corresponds with the file number" & @LF

$s_message = $s_message & "If No icon file is set the default is used." & @LF

MsgBox ( 64, "Compile Help", $s_message )

endfunc

Func ADLIBSection ( )

if WinExists ( 'Aut2Exe Error') then

AdlibDisable ( )

SplashOff ( )

WinWaitClose ( 'Aut2Exe Error')

Exit

endif

EndFunc

password generator code (written in perl)

#!/perl/bin -w

use strict;

use warnings;

# global vars

my @length = (8,12,16,20,24,28,32,36);

# these will be set in the gui or left at default

my($lenselected) = 1;

my($copytoclipboard) = 1;

my($numpwds) = 1;

my($stringtosend,$newpwd);

package Password;

use Win32::Clipboard;

use String::Random;

use Math::Random;

my($pass);

sub new {

$pass = new String::Random;

my $self = {};

bless $self;

}

sub GenPassword

{

my($i);

my($pattern, $X);

my($L, $U, $N, $S, $numpat)=0;

$stringtosend = '';

# create custom pattern

$pass->{'S'} = [ '#','$','_','+' ];

for($i=0;$i<$numpwds;$i++)

{

$pattern = '';

($numpat,$L,$U,$N,$S) = 0;

#set the pattern to n characters long divisable by 4

#in a random order

do

{

$X = random_uniform_integer(1,1,4);

SWITCH: for ($X)

{

/1/ && do { if($L lt ($length[$lenselected] /4)) {$pattern .= 'c'; $numpat++; $L++;} last; };

/2/ && do { if($U lt ($length[$lenselected] /4)) {$pattern .= 'C'; $numpat++; $U++;} last; };

/3/ && do { if($N lt ($length[$lenselected] /4)) {$pattern .= 'n'; $numpat++; $N++;} last; };

/4/ && do { if($S lt ($length[$lenselected] /4)) {$pattern .= 'S'; $numpat++; $S++;} last; };

}

} until $numpat eq $length[$lenselected];

$stringtosend .= "\n" . $pass->randpattern($pattern) if $stringtosend ne '';

$stringtosend = $pass->randpattern($pattern) if $stringtosend eq '';

}

}

sub SendtoClip

{

my($CLIP) = Win32::Clipboard();

$CLIP->Empty();

$CLIP->Set($stringtosend);

}

package main;

$newpwd = Password->new;

$newpwd->GenPassword;

$newpwd->SendtoClip;


SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

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