diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 466e7a2d..6b188167 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -89,7 +89,7 @@ android:name=".ui.error.IssueReporterActivity" android:theme="@style/IssueReporterTheme"/> - + diff --git a/app/src/main/assets/help/catalogue.json b/app/src/main/assets/help/catalogue.json index f14a7793..fe004096 100644 --- a/app/src/main/assets/help/catalogue.json +++ b/app/src/main/assets/help/catalogue.json @@ -39,6 +39,11 @@ "type": "markdown", "path":"documentation" }, + { + "title": "Android7.0以上点按与手势模拟", + "type": "markdown", + "path": "documentation" + }, { "title": "模块与第三方jar", "type": "markdown", diff --git a/app/src/main/assets/help/documentation/Android7.0以上点按与手势模拟.md b/app/src/main/assets/help/documentation/Android7.0以上点按与手势模拟.md new file mode 100644 index 00000000..e1152c94 --- /dev/null +++ b/app/src/main/assets/help/documentation/Android7.0以上点按与手势模拟.md @@ -0,0 +1,79 @@ +在Android7.0及以上,可以不需要root权限做到任意坐标的点击,滑动和手势模拟,并且比使用root权限的延迟更短。 + +**注意以下命令只有Android7.0及以上才有效** + +### click(x, y) +* x \ 要点击的坐标的x值 +* y \ 要点击的坐标的y值 + +模拟点击坐标(x, y),并返回是否点击成功。只有在点击执行完成后脚本才继续执行。 + +一般而言,只有点击过程(大约150毫秒)中被其他事件中断(例如用户自行点击)才会点击失败。 + +> 可以在开发者选项中启用指针位置来查看坐标 + +### longClick(x, y) + +* x \ 要长按的坐标的x值 +* y \ 要长按的坐标的y值 + +模拟长按坐标(x, y), 并 返回是否成功。只有在长按执行完成(大约600毫秒)时脚本才会继续执行。 + +一般而言,只有长按过程中被其他事件中断(例如用户自行点击)才会长按失败。 + +### press(x, y, duration) + +* x \ 要按住的坐标的x值 +* y \ 要按住的坐标的y值 +* duration \ 按住时长,单位毫秒 + +模拟按住坐标(x, y), 并返回是否成功。只有按住操作执行完成时脚本才会继续执行。 + +如果按住时间过短,那么会被系统认为是点击;如果时长超过500毫秒,则认为是长按。 + +一般而言,只有按住过程中被其他事件中断才会操作失败。 + +### swipe(x1, y1, x2, y2, duration) + +* x1 \ 滑动的起始坐标的x值 +* y1 \ 滑动的起始坐标的y值 +* x2 \ 滑动的结束坐标的x值 +* y2 \ 滑动的结束坐标的y值 +* duration \ 滑动时长,单位毫秒 + +模拟从坐标(x1, y1)滑动到坐标(x2, y2),并返回是否成功。只有滑动操作执行完成时脚本才会继续执行。 + +一般而言,只有滑动过程中被其他事件中断才会滑动失败。 + +### gesture(duration, \[x1, y1\], \[x2, y2\], ...) + +* duration \ 手势的时长 +* \[x, y\] \ 手势滑动路径的一系列坐标 + +模拟手势操作。例如`gesture(1000, [0, 0], [500, 500], [500, 1000])`为模拟一个从(0, 0)到(500, 500)到(500, 100)的手势操作,时长为2秒。 + +### gestures(\[delay, duration, \[x1, y1\], \[x2, y2\], ...], \[delay, duration, \[x3, y3\], \[x4, y4\], ...\], ...) + +同时模拟多个手势。每个手势的参数为\[delay, duration, 坐标\], delay为延迟多久(毫秒)才执行该手势;duration为手势执行时长;坐标为手势经过的点的坐标。其中delay参数可以省略,默认为0。 + +参见示例。 + + +### setScreenMetrics(width, height) + +* width \ 屏幕宽度,单位像素 +* height <\Number\> 屏幕高度,单位像素 + +设置脚本坐标点击所适合的屏幕宽高。如果脚本运行时,屏幕宽度不一致会自动放缩坐标。 + +例如在1920*1080的设备中,某个操作的代码为 +``` +setScreenMetrics(1080, 1920); +click(800, 200); +longClick(300, 500); +``` +那么在其他设备上AutoJs会自动放缩坐标以便脚本仍然有效。 + + + + diff --git a/app/src/main/assets/sample/安卓7.0+点按和手势/QQ刷一刷.js b/app/src/main/assets/sample/安卓7.0+点按和手势/QQ刷一刷.js new file mode 100644 index 00000000..2b3e2bc3 --- /dev/null +++ b/app/src/main/assets/sample/安卓7.0+点按和手势/QQ刷一刷.js @@ -0,0 +1,11 @@ +"auto"; + +launchApp("QQ"); +sleep(2000); + +while(true){ + if(currentPackage() == 'com.tencent.mobileqq'){ + swipe(600, 700, 600, 1400, 400); + } + sleep(300); +} \ No newline at end of file diff --git a/app/src/main/assets/sample/安卓7.0+点按和手势/三指下滑.js b/app/src/main/assets/sample/安卓7.0+点按和手势/三指下滑.js new file mode 100644 index 00000000..dee91eb3 --- /dev/null +++ b/app/src/main/assets/sample/安卓7.0+点按和手势/三指下滑.js @@ -0,0 +1,14 @@ +"auto"; + +/** + * 同时模拟三个手势: + * 从(300, 400)到(300, 1400) + * 从(600, 400)到(600, 1400) + * 从(900, 400)到(900, 1400) + * 每一个的时长都为350毫秒 + */ + +gestures([350, [300, 400], [300, 1400]], + [350, [600, 400], [600, 1400]], + [350, [900, 400], [900, 1400]] +); diff --git a/app/src/main/assets/sample/安卓7.0+点按和手势/三指捏合.js b/app/src/main/assets/sample/安卓7.0+点按和手势/三指捏合.js new file mode 100644 index 00000000..4a4b9f56 --- /dev/null +++ b/app/src/main/assets/sample/安卓7.0+点按和手势/三指捏合.js @@ -0,0 +1,10 @@ +"auto"; + +setScreenMetrics(1080, 1920); + +//如果你使用的是MIUI,此脚本运行后会出现桌面多屏幕编辑 +home(); +sleep(1500); +gestures([350, [800, 300], [500, 1000]], + [350, [300, 1500], [500, 1000]], + [350, [300, 300], [500, 1000]]); \ No newline at end of file diff --git a/app/src/main/assets/sample/安卓7.0+点按和手势/双指捏合.js b/app/src/main/assets/sample/安卓7.0+点按和手势/双指捏合.js new file mode 100644 index 00000000..74d7fa72 --- /dev/null +++ b/app/src/main/assets/sample/安卓7.0+点按和手势/双指捏合.js @@ -0,0 +1,9 @@ +"auto"; + +setScreenMetrics(1080, 1920); + +//如果你使用的是MIUI,此脚本运行后会出现桌面编辑 +home(); +sleep(1500); +gestures([500, [800, 300], [500, 1000]], + [500, [300, 1500], [500, 1000]]); \ No newline at end of file diff --git a/app/src/main/assets/sample/安卓7.0+点按和手势/心形手势.js b/app/src/main/assets/sample/安卓7.0+点按和手势/心形手势.js new file mode 100644 index 00000000..de5d70ca --- /dev/null +++ b/app/src/main/assets/sample/安卓7.0+点按和手势/心形手势.js @@ -0,0 +1,19 @@ +"auto"; + +toast("开启开发者选项-指针位置或者在画画软件才能查看效果"); + +setScreenMetrics(1080, 1920); + +var points = [10000]; +var interval = 0.1; +var x0 = 600; +var y0 = 1000; +var a = 120; + +for(var t = 0; t < 2 * Math.PI; t += interval){ + var x = x0 + a * (2 * Math.cos(t) - Math.cos(2 * t)); + var y = y0 + a * (2 * Math.sin(t) - Math.sin(2 * t)); + points.push([parseInt(x), parseInt(y)]); +} + +gesture.apply(null, points); diff --git a/app/src/main/assets/sample/安卓7.0+点按和手势/拉出通知栏.js b/app/src/main/assets/sample/安卓7.0+点按和手势/拉出通知栏.js new file mode 100644 index 00000000..60e0b6f0 --- /dev/null +++ b/app/src/main/assets/sample/安卓7.0+点按和手势/拉出通知栏.js @@ -0,0 +1,4 @@ +"auto"; + +//表示从位置(500, 10)滑动到位置(500, 1000), 持续两秒 +swipe(500, 10, 500, 1000, 2000); \ No newline at end of file diff --git a/app/src/main/assets/sample/安卓7.0+点按和手势/点击左上角.js b/app/src/main/assets/sample/安卓7.0+点按和手势/点击左上角.js new file mode 100644 index 00000000..74f97691 --- /dev/null +++ b/app/src/main/assets/sample/安卓7.0+点按和手势/点击左上角.js @@ -0,0 +1,5 @@ +"auto"; + +setScreenMetrics(1080, 1920); + +click(100, 150); \ No newline at end of file diff --git a/app/src/main/assets/sample/界面/QQ打开聊天窗口.js b/app/src/main/assets/sample/界面/QQ打开聊天窗口.js index 3fb77bd6..c0ddd404 100644 --- a/app/src/main/assets/sample/界面/QQ打开聊天窗口.js +++ b/app/src/main/assets/sample/界面/QQ打开聊天窗口.js @@ -1,24 +1,21 @@ "ui"; -importClass(android.widget.EditText); -importClass(android.widget.Button); -importClass(android.widget.LinearLayout); -importClass(android.content.Intent); -importClass(android.net.Uri); +ui.statusBarColor("#03a9f4"); -var qq = new EditText(activity); -qq.setHint("请输入QQ号"); -var btnOk = new Button(activity); -btnOk.setText("确定"); -var container = new LinearLayout(activity); -container.addView(qq); -container.addView(btnOk); -activity.setContentView(container); +ui.layout( + + QQ打开聊天窗口 + + +