Write the first script (Hello World) with AutoIt _autoit

Source: Internet
Author: User

(Note: If you have already installed the SciTE editor, it will edit the script instead of the system's own Notepad.) )

First open the folder you want to create the script, click the right mouse button and then select new /autoit v3 script in the menu.

Name the script file as helloworld.au3. Note the extension should be . au3-- This indicates that the file is a AutoIt v3 script.

We've created the script file, and now all we have to do is edit the script so that it has the functionality we need. Right-click the helloworld.au3 script file and select Edit Scriptin the menu.

You will then use the Notepad program to open the script, and you will see something like this:

The code you see is nothing more than a comment that facilitates organizing scripts. It also prompts for "options" to be used later. Each line of the code begins with a semicolon, so they will be interpreted as annotations to the script (that is, it will be ignored), similar to the DOS-ignored command line specified in the batch file in the DOS.

Well, now we're going to tell AutoIt what to do is display an information box--the MSGBOX function can be implemented.

Add the following at the bottom of the code:

MsgBox (0, "guide", "Hello world!")

All functions have parameters, and the MsgBox function has three parameters--identification, title, and information. The number in the ID is used to change the display style of the message box-we try 0now. Both the title and the information are string arguments--the string must be enclosed in double quotes or single quotes for the text in the AutoIt, which means that "this is some text" or "This is some text".

Save the script and close Notepad. Now that you've written your own first AutoIt script! To run this script you simply double-click the helloworld.au3 file (or you can right-click the script and choose Run Scriptin the menu).

You should see a message box like this:

Now let's look at the identification of this parameter in the MsgBox function. We see a number of values listed in the Guide page of this function that are used to change the display style of the information box. A value of 0 displays a concise information box with a single OK button. If the value is, a message box with an exclamation point icon appears.

Open the script again to edit, and change the argument from 0 to 64:

MsgBox (64, "Guide", "Hello world!")

This message box appears when you run the script:

You can experiment on your own to see what happens when you set different values for the identity parameters. Keep in mind that if you need to apply more than one identity value, just add those values together.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.