Nói chung, các hàm này đã được liệt kê và hướng dẫn hết sức chi tiết về cách sử dụng trong file Help của AutoIt, do đó việc kể tên ra đây là vô nghĩa và ko cần thiết
Hãy thử ví dụ với script sau, được dùng để tự động hóa quá trình cài đặt WinZip - giả lập bàn phím và gửi các phím cần thiết tới trình cài đặt:
Code:
; Run the winzip
installer
Run("winzip90.exe")
; Initial Setup
Screen
WinWaitActive("WinZip® 9.0 SR-1 Setup",
"&Setup")
Send("!s")
; Install
location
WinWaitActive("WinZip Setup", "into the
following folder")
Send("{ENTER}")
; Features
overview
WinWaitActive("WinZip Setup", "WinZip
features include")
Send("!n")
; License
agreement
WinWaitActive("License
Agreement")
Send("!y")
; Quick start
WinWaitActive("WinZip Setup", "Quick Start
Guide")
Send("!n")
; Choose
interface
WinWaitActive("WinZip Setup", "switch
between the two interfaces")
Send("!c")
Send("!n")
; Installation type
(custom/express)
WinWaitActive("WinZip Setup",
"&Express setup (recommended)")
Send("!e")
Send("!n")
; Select file
associations
WinWaitActive("WinZip Setup", "WinZip
needs to associate itself with your archives")
Send("!n")
; Completed installation
screen
WinWaitActive("WinZip Setup", "Thank you
for installing this evaluation version")
Send("{ENTER}")
; Wait for winzip to load
then close it
WinWaitActive("WinZip (Evaluation
Version)")
WinClose("WinZip (Evaluation
Version)")
Hoặc, vài ba lệnh dùng để tương tác với registry:
Code:
; Write a single REG_SZ
value
RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Test",
"TestKey", "REG_SZ", "Hello this is a test")
; Write the REG_MULTI_SZ
value of "line1" and "line2"
RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Test",
"TestKey1", "REG_MULTI_SZ", "line1" & @LF & "line2")
Một lời khuyên duy nhất: Bạn chỉ cần file Help + Forum của AutoIt để làm mọi thứ
Các hàm do người dùng tự định nghĩa
Các hàm này, nằm trong các file au3 được phân phối kèm với AutoIt. Điểm phân biệt hàm này với các hàm built-in là ở tên của hàm - Hàm tự định nghĩa thường có dấu gạch dưới ở trước tên, hàm built-in thì ko.
Để sử dụng các hàm tự định nghĩa, bạn cần include file mã nguồn của hàm vào script mình đang thực hiện. Ví dụ:
Code:
#include
<date.au3>
MsgBox(0,"Today","Today's date is "
& Now())
Số lượng hàm tự định nghĩa rất nhiều và có thể được lấy về từ autoitscript.com
Identical(UDS)
0 nhận xét