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',
Gravity="center_horizontal",
id="e1",
textColor="#ffffff00",
layout_width=-1,
layout_height="10%h",
layout_weight=1,
},
{
EditText,
text="1000",
hint="输入循环周期(以毫秒为单位)",
HintTextColor='#ffffff00',
Gravity="center_horizontal",
id="e2",
textColor="#ffffff00",
layout_width=-1,
layout_height="10%h",
inputType="number",
layout_weight=1,
},
{
EditText,
hint="循环次数",
HintTextColor='#ffffff00',
id="e3",
Gravity="center_horizontal",
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,},
{Button,
text="复制次数循环代码",
onClick="fzcsxhdm",
textColor="#ffffff00",
layout_width=-1,
layout_height="10%h",
layout_weight=1,},
{Button,
text="复制无限循环代码",
onClick="fzwxxhdm",
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
function fzcsxhdm()
local t,str={},e1.text or ""
for s in str:gmatch"[^\n]+"
table.insert(t,"\""..s.."\",")
end
if #t>0
service.copy("点击列表={{{"..table.concat(t).."}}}\n按钮列表={}\nfunction append(t1,t2)\nfor k,v in ipairs(t2) do\ntable.insert(t1,v)\nend\nend\nfor n=1,"..tonumber(e3.text).." do\nappend(按钮列表,点击列表)\nend\nif service.click({按钮列表})\nreturn true\nend")
end
end
function fzwxxhdm()
local t2,str={},e1.text or ""
for s in str:gmatch"[^\n]+"
table.insert(t2,"\""..s.."\",")
end
if #t2>0
service.copy("require \"import\"\nimport \"com.androlua.Ticker\"\nif ti then\nti.stop()\n service.speak(\"停止\")\n ti=nil\n return true\nend\nti=Ticker()\nti.Period="..tonumber(e2.text).."ti.onTick=function()\nservice.click({{"..table.concat(t2).."}})\nend\nti.start()\nservice.speak(\"开始\")")end
end
来自解说社区客户端 |