2~控件点击是autojs左右特点的一项功能,它是基于安卓的无障碍功能的,在软件上有很好的支持,但是游戏就不行了。具体的教程很多,不多说了,就说说我在使用时踩得一些坑。
①有些控件能用autojs的工具找到,但是写出来后却识别不出来,手动滑动一下屏幕就能找到了,不知道是不是BUG,所以加个判断,防止找不到脚本出错
②寻找控件建议不要用findOne()、waitFor()、exists()等一些会阻塞的方法,不然稍微出现一点其他事件就会阻塞,导致脚本莫名其妙的卡死,使用findOne(timeout)、findonce()时可以加个判断在不为null的时候再点击或其他操作,因为没找到返回null,直接click就会报错,脚本停止运行,要是是找的父或者子控件也写到判断里
③找图找色特别消耗内存,所以在能用控件就用控件,找图找色在找到后要用recycle()来对创建的图像对象回收,提高脚本稳定,让脚本能持续运行更长时间,截图也需要一定的时间
④如果脚本有悬浮窗,使用找图要注意不要将要找的图遮挡
⑤控件中使用text比id要靠谱一些,在一些软件中id是会改变的
ps:如果有问题可以在评论区评论,会的我会解答,不定时更新,可以点点关注和小心心哦
1.首先写一个js文件,areaLocation.js:
var
provinceArray=
new
Array()
provinceArray=[
{"pname":"江苏",
"country":[
{
"cname":"南京市",
"town":["玄武区","白下区","秦淮区","建邺区","雨花台","江宁区",
"六合区","溧水县","高淳县"]},
{
"cname":"南通市",
"town":["崇川区","港闸区","启东市","如皋市","通州市","海门市","海安县","如东县"]
},
{
"cname":"苏州市",
"town":["金阊区","沧浪区","平江区","虎丘区","吴中区","张家港","昆山市","吴江市","太仓市"]
}
]
},
{"pname":"上海",
"country":[
{
"cname":"上海市",
"town":["徐汇区","普陀区","杨浦区","虹口区","卢湾区","浦东区","黄浦区","长宁区","闸北区","静安区","闵行区","松江区"]
}
]
}
]
function
areaInitialize(){
province.length=1
for(var
i
=
0i<provinceArray.lengthi++){
var
pro
=
provinceArray[i].pname
province.options[province.length]
=
new
Option(pro,pro)
}
}
function
changeCLocation(id,city){
//alert(id)
city.length
=
0
if(id>0){
var
j=id-1
var
i
var
countrys
=
new
Array()
countrys
=
provinceArray[j].country
city.options[0]
=
new
Option('不限','')
for
(i=0i
<
countrys.length
i++){
var
cname
=
countrys[i].cname
city.options[city.length]
=
new
Option(cname,
cname)
}
changeTLocation(id,1,town)
}else
if(id==0){
city.length
=
0
town.length
=
0
city.options[city.length]
=
new
Option('不限','')
town.options[town.length]
=
new
Option('不限','')
}
}
function
changeTLocation(pid,cid,town){
//alert(cid)
var
countrys
=
new
Array()
var
towns
=
new
Array()
town.length
=
0
var
i
countrys
=
provinceArray[pid-1].country
areaId
=
countrys[cid-1].areaId
towns
=
countrys[cid-1].town
city.options[0]
=
new
Option('不限','')
town.options[0]
=
new
Option('不限','')
for
(i=0i
<
towns.length
i++){
var
tname
=
towns[i]
town.options[town.length]
=
new
Option(tname,tname)
}
town.options[0]
=
new
Option('不限','')
}
2.
再写一个html页面:
<!DOCTYPE
HTML
PUBLIC
"-//W3C//DTD
HTML
4.01
Transitional//EN">
<html>
<head>
<script
type="text/javascript"
></script>
<script
type="text/javascript">
window.onload=areaInitialize()
</script>
</head>
<body>
<select
size="1">
<option
value=0
selected>--请选择--</option>
</select>
<select
size="1"
>
<option
value=0
selected>--请选择--</option>
</select>
<select
size=1>
<option
value=0
selected>--请选择--</option>
</select>
</body>
</html>