グローバルショートカット
Android Macro は、クラスメソッドに加えて便利な Lua ショートカットをいくつか提供しています。よく使う呼び出しの古くて短い名前で、互換性のために残されています。
画面のショートカット
| ショートカット | 相当する呼び出し |
|---|---|
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() | width() と height() 関数を持つテーブル |
ユーティリティのショートカット
| ショートカット | 相当する呼び出し |
|---|---|
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) |
例
local size = getScreenSize()
toast("Screen: " .. size.width() .. " x " .. size.height())
if exist("home.png") then
click("home.png")
end
注記
- 古い2引数形式のスコア指定
click(template, score)、exist(template, score)、existClick(template, score)はScreen:setMatchingSimilarityを呼び出しますが、これは現在の SDK には含まれていません。代わりにFinderParams():setScore(score)を使ってください。 wait(template, timeout)はScreen:wait()のショートカットではありません。この名前はスリープ形式に使われます。画像やテキストを待つ場合は、Screen:wait(template, timeout)を明示的に呼び出してください。