require "import"
import "com.androlua.Ticker"
import "android.widget.*"
import "android.view.*"
if ti then
ti.stop()
service.speak("停止")
ti=nil
return true
end
layout=
{
LinearLayout,
orientation=1,
layout_width=-1,
layout_height=-1,
{
EditText,
hint="输入关键字",
HintTextColor='#ffffff00',
id="e1",
textColor="#ffffff00",
layout_width=-1,
layout_height="10%h",
layout_weight=1,
},
{
EditText,
text="1000",
hint="输入循环周期(以毫秒为单位)",
HintTextColor='#ffffff00',
id="e2",
textColor="#ffffff00",
layout_width=-1,
layout_height="10%h",
inputType="number",
layout_weight=1,
},
{
EditText,
hint="循环次数",
HintTextColor='#ffffff00',
id="e3",
textColor="#ffffff00",
layout_width=-1,
layout_height="10%h",
inputType="number",
layout_weight=1,
},
{Button,
text="无限循环,再次启动插件退出",
onClick="wxxh",
textColor="#ffffff00",
layout_width=-1,
layout_height="10%h",
layout_weight=1,},
{Button,
text="开始次数循环",
onClick="xhdj",
textColor="#ffffff00",
layout_width=-1,
layout_height="10%h",
layout_weight=1,},}
dlg=LuaDialog()
.setView(loadlayout(layout))
.show()
function wxxh()
if e1.text==""
print("请输入关键字")
else
dlg.hide()
ti=Ticker()
ti.Period=tonumber(e2.text)
ti.onTick=function()
local t,str={},e1.text or ""
for s in str:gmatch"[^\n]+"
table.insert(t,s)
end
if #t>0
service.click({t})
end
end
ti.start()
service.speak("开始")
end
end
function xhdj()
if e3.text==""
print("请输入循环次数")
else
dlg.hide()
local t,str={},e1.text or ""
for s in str:gmatch"[^\n]+"
table.insert(t,s)
end
if #t>0
点击列表=t
按钮列表={}
function append(t1,t2)
for k,v in ipairs(t2) do
table.insert(t1,v)
end
end
for n=1,tonumber(e3.text) do
append(按钮列表,点击列表)
end
task(500,function()
if service.click({按钮列表}) then
return true
end
end)
end
end
end
来自解说社区客户端 |