Lewati ke konten utama

Pintasan Global

Android Macro menyediakan beberapa pintasan Lua selain metode kelas. Ini adalah nama yang lebih lama dan lebih pendek untuk panggilan umum, dan tetap dipertahankan untuk kompatibilitas.

Pintasan layar​

PintasanEkuivalen
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()Tabel dengan fungsi width() dan height()

Pintasan utilitas​

PintasanEkuivalen
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)

Contoh​

local size = getScreenSize()
toast("Screen: " .. size.width() .. " x " .. size.height())

if exist("home.png") then
click("home.png")
end

Catatan​

  • Bentuk skor dua argumen yang lama click(template, score), exist(template, score) dan existClick(template, score) memanggil Screen:setMatchingSimilarity, yang bukan bagian dari SDK saat ini. Gunakan FinderParams():setScore(score) sebagai gantinya.
  • wait(template, timeout) bukan pintasan untuk Screen:wait(); nama itu dipakai untuk bentuk sleep. Gunakan Screen:wait(template, timeout) secara eksplisit saat menunggu gambar atau teks.