Skip to main content

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​

ShortcutEquivalent
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​

ShortcutEquivalent
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) and existClick(template, score) call Screen:setMatchingSimilarity, which is not part of the current SDK. Use FinderParams():setScore(score) instead.
  • wait(template, timeout) is not a shortcut for Screen:wait(); the name is used for the sleep form. Use Screen:wait(template, timeout) explicitly when waiting for an image or text.