Global shortcuts
Android Macro exposes a few Lua shortcuts in addition to the class methods. They are older, shorter names for common calls and are kept for compatibility.
Screen shortcuts
| Shortcut | Equivalent |
|---|---|
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() | Table with width() and height() functions |
Utility shortcuts
| Shortcut | Equivalent |
|---|---|
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) |
Example
local size = getScreenSize()
toast("Screen: " .. size.width() .. " x " .. size.height())
if exist("home.png") then
click("home.png")
end
Notes
- The old two-argument score forms
click(template, score),exist(template, score)andexistClick(template, score)callScreen:setMatchingSimilarity, which is not part of the current SDK. UseFinderParams():setScore(score)instead. wait(template, timeout)is not a shortcut forScreen:wait(); the name is used for the sleep form. UseScreen:wait(template, timeout)explicitly when waiting for an image or text.