Phím tắt toàn cục
Android Macro cung cấp thêm một vài phím tắt Lua bên cạnh các phương thức của lớp. Chúng là những tên cũ, ngắn hơn cho các lời gọi thông dụng và được giữ lại để tương thích.
Phím tắt màn hình
| Phím tắt | Tương đương |
|---|---|
click(x, y) | Screen:click(x, y) |
click(template) | Screen:click(template) |
find(template) | Screen:find(template) |
exist(template) | Screen:exist(template) |
existClick(template) | Screen:existClick(template) |
swipe(points, params) | Screen:swipe(points, params) |
getScreenSize() | Bảng có các hàm width() và height() |
Phím tắt tiện ích
| Phím tắt | Tương đương |
|---|---|
toast(text, ms) | Utils:toast(text, ms) |
alert(text, title) | Utils:alert(text, title) |
sleep(ms) | Utils:sleep(ms) |
wait(ms) | Utils:sleep(ms) |
Point(x, y) | point:newInstance(x, y) |
Color(hex) | color:newInstance(hex) |
Ví dụ
local size = getScreenSize()
toast("Screen: " .. size.width() .. " x " .. size.height())
if exist("home.png") then
click("home.png")
end
Lưu ý
- Các dạng điểm số hai tham số cũ
click(template, score),exist(template, score)vàexistClick(template, score)gọiScreen:setMatchingSimilarity, hàm này không có trong SDK hiện tại. Hãy dùngFinderParams():setScore(score)thay thế. wait(template, timeout)không phải phím tắt củaScreen:wait(); tên này được dùng cho dạng tạm dừng. Hãy dùngScreen:wait(template, timeout)một cách tường minh khi chờ một hình ảnh hoặc văn bản.