使用 Aut2Exe 编译脚本

这是一个标准的方法来编译您的 .au3 脚本到 独立的 可执行文件; 这个可执行文件可以在没有安装 AutoIt 的机器上运行,并且也不需要机器中带有 AutoIt3.exe. 此外, the compiled script is compressed and encrypted and there is the option to bind additional files (also compressed/encrypted) to the exe using the FileInstall function. Also, any #include files will also be compiled into the script so they are not required at run-time.

注:这些信息可能不能适用于汉化版本,只是为使用英文原版的同志,以及有兴趣的朋友作个参考


小心: 在编译您的脚本前,您必须检查您的脚本语法表达式是否正确,编译器不会对您的脚本进行语法检查.

 

Aut2Exe 可以有三种使用方法:

方法 1 - 开始菜单

只在完整安装有效(汉化版本因为有强大的ACNWrapper/AutoIt3Wrapper所以去掉快捷方式,这里只是给使用英文原版的做个介绍).

1.  点击开始菜单并浏览 AutoIt v3 组.

2.  点击 Script Compiler \ Convert .au3 to .exe

3.  Aut2Exe 主界面就应该出现.

       

4.  使用 Browse(英文版)/浏览(B)(汉化版) 按钮选择您的输入 (.au3) 和输出 (.exe) 文件.

5.  If you like you can change the icon of the resulting .exe - just browse to the icon you want (some example icons are supplied in Program Files\AutoIt3\Aut2Exe\Icons).

6.  The only other option you might wish to change is the compression level (especially if using FileInstall to add extra files). Use the Compression menu to set this. As with all compression routines the better the compression you select the slower it will be. However, no matter what compression level you select the decompression speed (when the .exe is run) is the same.

7.  Click on Convert to compile the script.

Note: scripts can be compile with .a3x extension. They should be run with AutoIt.exe filename.a3x. The .a3x contains the script itself with all referred #include plus the FileInstall files. This format allows you to distribute smaller files as they don't include the AutoIt3.exe in each compiled script. You still need to have it accessible on the target machine but just AutoIt3.exe.

 

方法 2 - 右键点击

只在完整安装有效(汉化版已使用ACNWrapper工具替代).

1.  在资源管理器里面找到您需要编译的脚本文件(.au3).

2.  在脚本文件上面点击右键.

       

3.  The file will be silently compiled with the same filename - just with a .exe extension.

When compiling in this way, Aut2Exe uses current icon/compression settings (from the last time Aut2Exe was run manually as in method 1).

 

方法 3 - 命令行

Aut2Exe.exe 程序可以运行于下列命令行:

    Aut2exe.exe /in <infile.au3> [/out <outfile.exe>] [/icon <iconfile.ico>] [/comp 0-4] [/nopack] [x64] [/bin <binfile.bin>]

Where

参数 用法 默认值
/in <infile.au3> 指定要进行编译的脚本的完整路径. 无. 输入文件 必须 指定
/out <outfile.exe> 指定编译后,生成的可执行文件的完整路径.
<outfile.a3x> 指定编译后,生成的已编译文件(*.a3x)的完整路径.
和输入脚本文件名相同,但是扩展名为 .exe
/icon <iconfile.ico> 指定已编译可执行文件要使用的图标的完整路径. 默认 AutoIt 图标
/comp 指定编码脚本使用的压缩等级 (这个和 UPX 加壳压缩没关系).
它只能是数字的 0(无) 和 4 (最大).[原文档是and(和)不是to(到)]
2
/nopack 指定输出的可执行文件不进行外部的 UPX 压缩. 压缩
/pack 指定输出的可执行文件进行外部的 UPX 加壳压缩. 压缩
/x64 指定输出的可执行文件为 x64 系统构架的程序. 参考说明
/x86 Specifies that the script should be compiled for use on systems with x86 (32-bit) architecture. see notes
/console 指定输出的文件为一个控制台程序. Windows 应用程序 (/gui)
/gui 指定输出的文件为一个 Windows 应用程序. Windows 应用程序 (/gui)
/bin <binfile.bin> 指定根文件(AU3脚本的执行体)的完整路径. 在 Aut2exe 文件夹中搜索

命令行例子

/in c:\myscript.au3 /out c:\myapp.exe /icon c:\myicon.ico /x64

Will result in the creation of c:\myapp.exe with normal compression which will use the specified icon and be compiled for use on x64 system architecture.

/in c:\myscript.au3

will result in the creation of a unicode c:\myscript.exe with normal compression which will use the default AutoIt icon for use on win_32 systems.

命令行说明

Long filenames should be enclosed in double-quotes like "C:\Program Files\Test\test.au3".

With the exception of /in all switches are optional.

By default, the 32-bit compiler produces a 32-bit binary and the 64-bit compiler produces a 64-bit binary. Use the /x86 and /x64 parameters to explicitly specify the output.

The /pass and /nodecompile switches are redundant as of version 3.2.8.1. They will be ignored if used and have been removed from this list.

/ansi 和 /unicode 开关在 3.3.0.0 版本后已经是多余的.

技术细节

被编译的脚本将会附加在根文件(AU3脚本的执行体)末尾, FileInstall 使用我(Jon)自己的压缩算法进行压缩.