ShareHolder Finder v0.9.3 is now released!!! Check Product Page for more details.


Saturday, 13 February 2016

AutoIt - Hello World

Author Post Date Saturday, 13 February 2016
Lets start writing the code. We will script for displaying a simple message box in this post.
AutoIt Simple Message Box - Hello World

Step-by-Step Procedure for the first AutoIt Script

  1. Open the AutoIt script editor through Windows start menu -> AutoIt v3 -> SciTE Script Editor OR
  2. Create a new script file using windows right click menu and selecting New -> AutoIt v3 Script.
  3. Copy and paste the below code to editor. Program explanation is provided below.
  4. Save the script.

;Includes the file which defines the constants to be used with MsgBox function.
#include <MsgBoxConstants.au3>

;Calls the inbuilt Message Box Function.
MsgBox($MB_ICONINFORMATION, "Automation Developers", "Hello World!")

Program Explanation

  1. The first and third lines are comments, which will not be executed. The comments are a way to provide more information to script readers and of-course to comment-out the code, so that it won't be executed. More information on comments are provided in Add Comments post.
  2. #include <MsgBoxConstants.au3>: This is how we include files. So that its variables and functions are accessible from our script. Syntax: #include <FileName>. How to easily open an include file?
  3. MsgBox($MB_ICONINFORMATION, "Automation Developers", "Hello World!"): This is the code which displays our message box. MsgBox is an inbuilt function and its syntax is 
          MsgBox ( flag, "title", "text" [, timeout = 0 [, hwnd]] )
    • flag: The flag indicates the type of message box and the possible button combinations. Here we used information message.
    • title: The title of the message box. Here it is "Automation Developers"
    • text: The text of the message box. Here it is "Hello World!"
    • timeout: [optional] Timeout in seconds. Message box will be automatically closed after the timeout. The default is 0, which is no timeout.
    • hwnd: [optional] The window handle to use as the parent for this dialog. The message box will be tied to this window.

How to Run the script?

    Select Tools -> Go command or press F5 to run the script.
    It will syntax check the script using Au3Check.exe and if no errors are found, will run the script using AutoIt3.exe.
    Selecting Tools -> SyntaxCheck Prod or pressing Ctrl+F5 will run only Au3Check.exe for checking the syntax errors.

How to Compile or Build the script? - Create Executable (.exe)

    Select Tools -> Build command or press F7 to build the script. 
    It will run Aut2exe.exe to compile the script. The output executable will be available at the same folder where the script is located.
    Alternatively, select Tools -> Compile command or press Ctrl+F7to compile the script with options such as compression value, icon and the program resource information like Program Version, Legal Copyright and additional fields.


    Output message box will be displayed as shown in the above screenshot.
Related Posts

Interesting? Share and Let Others Know.

Post a comment