Keyword Reference


#pragma

A special directive for controlling aspects of how the script is compiled.

#pragma pragma-option

Parameters

pragma-option compile

Remarks

See pragma directives for more details.

Example

Example 1

#pragma compile(Out, myProg.exe)
; Uncomment to use the following icon. Make sure the file path is correct and matches the installation of your AutoIt install path.
; #pragma compile(Icon, C:\Program Files\AutoIt3\Icons\au3.ico)
#pragma compile(ExecLevel, highestavailable)
#pragma compile(Compatibility, win7)
#pragma compile(UPX, False)
#pragma compile(FileDescription, myProg - a description of the application)
#pragma compile(ProductName, myProg)
#pragma compile(ProductVersion, 3.7)
#pragma compile(FileVersion, 3.7.0.0, 3.7.100.201) ; The last parameter is optional.
#pragma compile(LegalCopyright, © Joe Bloggs)
#pragma compile(LegalTrademarks, '"Trademark something, and some text in "quotes" etc...')
#pragma compile(CompanyName, 'Joe Bloggs & Co')

#include <MsgBoxConstants.au3>

If @Compiled Then
        Example()
Else
        MsgBox($MB_SYSTEMMODAL, "", "Please compile before running.")
EndIf

Func Example()
        ; Retrieve the file version of the AutoIt executable.
        Local $sFileVersion = FileGetVersion(@AutoItExe)

        ; Display the file version. This should be equal to @AutoItVersion.
        MsgBox($MB_SYSTEMMODAL, "", $sFileVersion)
EndFunc   ;==>Example

Example 2

; use Out option to compile to a3x file
#pragma compile(Out, pragma[2].a3x)
#include <MsgBoxConstants.au3>

MsgBox($MB_ICONINFORMATION, @ScriptName, 'Is compiled ? ... ' & @Compiled)

Example 3

#pragma compile(Out, pragma[3].exe)
; use AutoItExecuteAllowed option to allow running au3 or a3x file using this compiled EXE as an interpreter
#pragma compile(AutoItExecuteAllowed, true)

#REMARK before you use this example you must firstly compile pragma[2].au3
#include <MsgBoxConstants.au3>

_Example()

Func _Example()
        Local $iPID_au3 = Run(@ScriptFullPath & ' /AutoIt3ExecuteScript "' & @ScriptDir & '\pragma[2].au3"')
        While ProcessExists($iPID_au3)
                Sleep(10)
        WEnd
        MsgBox($MB_ICONINFORMATION, 'Check 1', 'After running pragma[2].au3')

        Local $iPID_a3x = Run(@ScriptFullPath & ' /AutoIt3ExecuteScript "' & @ScriptDir & '\pragma[2].a3x"')
        While ProcessExists($iPID_a3x)
                Sleep(10)
        WEnd
        MsgBox($MB_ICONINFORMATION, 'Check 2', 'After running pragma[2].a3x')

EndFunc   ;==>_Example