Autoit automated programming (4)

Source: Internet
Author: User

V. Automated operations Quick Start Series 5

Control Operations
However, it is often difficult to achieve the expected goal only by relying on the above technologies. The following describes the most important control operations.
1. Set text
During software installation, users often need to provide necessary information, such as the installation directory. Many users do not like to install the software to the default C drive, but prefer to install them elsewhere. So what method does the script provide for us to modify the path shown in?

We first use the autoit3 window spy or autoit window info mentioned above to obtain the information of the editing box for this path. Assume that the title of this window is setup foobar, the class name in the path editing box is edit1, and we need to change it to "D: \ foobar2000". Then we can use the following command/function to set its text:
Ahk:
Controlsettext [, target control, new text, window title, window text, exclude title, exclude text]
Au3:
Controlsettext ("window title", "window text", Control ID, "new text ")
The usage is as follows:
[Example 5.1.1]
Ahk:
Controlsettext, edit1, D: \ foobar2000, setup foobar
Au3:

Controlsettext ("setup foobar", "", "edit1", "d: \ foobar2000 ")

2. Select and deselect the single-choice and check-box items
SometimesProgramIn order to satisfy users' personalized settings, users need to provide more information. We often encounter this situation:

How can I ensure that the required project is selected and some projects are canceled?
The following describes the commands/functions used in Ahk and au3 to set various attributes of controls:
Ahk:
Control [, command, value, target control, window title, window text, exclude title, exclude text]
Au3:
Controlcommand ("window title", "window text", Control ID, "command", "option ")

The "command" specifies the parameters to be set. For these single button/check box buttons, the applicable commands are "check" and "uncheck ".
Assume that the title of the window is setup foobar. We plan to perform the following operations:
Select its "desktop" check box (button5), deselect the "Quick Start" check box (button7 );
Select "0.7x" (button14 ).

The usage example is as follows:
[Example 5.1.2]
Ahk:
Control, check, button5, foobar
Control, uncheck, button7, foobar
Control, check, button14, foobar
Au3:

Controlcommand ("foobar", "", "button5", "check ","")
Controlcommand ("foobar", "", "button7", "uncheck ","")
Controlcommand ("foobar", "", "button14", "check ","")

2. Select a project from the drop-down list.
I believe you have encountered the following situation:

The question is: how to select the project you need?
The answer is to use the commands/functions mentioned above. For such controls, the commands applicable to Ahk are "choose, N" and "choosestring, string", which respectively indicate that the nth project is selected and the project that matches the string is selected; the applicable commands for au3 are "setcurrentselection, N" and "selectstring, string", respectively, indicating the n + 1 Selected (note that it is expressed from scratch !) Project and the project that matches the string.

Suppose we want to select the fifth project "simplified Chinese", the specific usage example is as follows:

[Example 5.1.3]
Ahk:
Control, choose, 5, combox1, Installer
Control, choosestring, simplified Chinese, combox1, Installer
Au3:
Controlcommand ("Installer", "", "combox1", "setcurrentselection", 4)
Controlcommand ("Installer", "", "combox1", "selectstring", "simplified Chinese ")

Detailed source reference: http://www.jb51.net/article/14870_5.htm

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.