add: LICENSE, ui mode

This commit is contained in:
hyb1996
2017-02-05 20:57:04 +08:00
parent 407066027e
commit 13142d14a7
52 changed files with 732 additions and 215 deletions

View File

@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
@@ -20,4 +21,13 @@
</android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout>
<TextView
android:id="@+id/error"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="16dp"
android:scrollbars="vertical"
android:textColor="@android:color/secondary_text_light"
android:textSize="16sp"
tools:text="错误"/>
</LinearLayout>

View File

@@ -40,7 +40,7 @@
android:layout_height="20dp"
android:layout_alignParentLeft="true"
android:layout_margin="16dp"
android:src="@drawable/ic_service_green"/>
android:src="@drawable/ic_robot_head_green"/>
<TextView
android:layout_width="wrap_content"

View File

@@ -74,7 +74,7 @@
android:layout_height="20dp"
android:layout_alignParentLeft="true"
android:layout_margin="16dp"
android:src="@drawable/ic_service_green"/>
android:src="@drawable/ic_robot_head_green"/>
<TextView
android:layout_width="wrap_content"

View File

@@ -4,21 +4,31 @@
###二、自动操作函数
**自动操作的函数都需要开启"自动操作服务"才能执行,否则执行到相应函数时脚本会停止运行。**
* `click(text)` 点击文本text所在的区域并返回是否点击成功。当前界面没有出现该文本或者该文本所在区域不可点击时返回false。例如`click("发现")`,是点击"发现"。如果要点击"发现"直至点击成功可以用`while(!click("发现"))`
> 文本所在区域指的是,从文本处向寻找,直至发现一个可点击的部件为止。
* `click(left, top, bottom, right)` 点击与长方形范围严格匹配的区域并返回是否点击成功。其中left为长方形左边与屏幕左边的像素距离top为上边与屏幕上边的像素距离right为右边与**屏幕左边**的像素距离, bottom为下边与**屏幕下边**的距离。区域严格匹配,至于要确定要点击的区域在屏幕上的左边位置,可以在侧拉菜单开启"脚本辅助"或者安卓7.0以上在通知栏点击"修改"添加脚本辅助快捷设定图标),之后每次点击或长按事件都会提示这次点击或长按的区域并自动保存,可以在编辑器中插入。
> 文本所在区域指的是,从文本处向其父视图寻找,直至发现一个可点击的部件为止。
* `click(left, top, bottom, right)`
> 有些按钮或者部件是图标而不是文字例如发送朋友圈的照相机图标以及QQ下方的消息、联系人、动态图标这时不能通过`click(text)`来点击只能通过描述图标所在的区域来点击。left, bottom, top, right描述的就是点击的区域。至于要定位点击的区域可以在侧拉菜单开启"点击区域辅助"或者安卓7.0以上在通知栏点击"修改"添加点击区域辅助快捷设定图标),之后每次点击或长按都会提示这次点击或长按的区域并自动保存,可以在编辑器的右侧拉菜单中插入。
点击与长方形范围严格匹配的区域并返回是否点击成功。其中left为长方形左边与屏幕左边的像素距离top为上边与屏幕上边的像素距离right为右边与**屏幕左边**的像素距离, bottom为下边与**屏幕上边**的距离。区域严格匹配。
> 以下的longClick、select、scrollUp、scrollDown的参数均与click类似不再赘述。
* `longClick` 长按
* `select` 选择
* `scrollUp` 上滑。不加参数时会寻找"最大"的可滑动的控件滑,例如微信消息列表等。
* `scrollUp` 上滑。不加参数时会寻找"最大"的可滑动的控件滑,例如微信消息列表等。
* `scrollDown` 下滑。不加参数时与scrollUp类似。
* `input(string)` 把所有输入框的文本都置为string
* `input(text)` 把所有输入框的文本都置为text。例如input("测试")
* `input(i, text)` 把第i个输入框的文本设为text。i从0开始。
###三、其他函数
* `sleep(n)` 暂停执行n**毫秒**时间。
* `toast(string)` 显示提示文本。
* `toast(text)` 显示提示文本。
* `launch(packageName)` 运行包名为packageName的应用。例如launch("com.tencent.mm")是运行微信应用包名可以通过一些工具获取获取通过函数launchApp代替
* `launch(packageName, className)` 运行包名为packageName类名(Activity)为className的应用。
* `launchApp(appName)` 运存应用名称为appName的应用。例如launchApp("QQ")。不同应用名称可能相同,这时只运行其中某一个应用。
###四、在脚本中调用安卓
* `notStopped` 若当前脚本处于运行状态时返回`true`, 否则返回`false`。对于某些循环, 例如`while(true)`,请用`while(notStopped())`代替,以免死循环造成的脚本无法正常停止。
* `isStoppd` 若当前脚本处于停止状态时返回`true`, 否则返回`false`
###四、全局变量
* `context` ApplicationContext参见安卓[android.content.Context](https://developer.android.com/reference/android/content/Context.html)
> 这里的context由于是ApplicationContext是不可见的不能用于dialog和其他UI相关。如果要显示弹窗或者视图请启动UI模式代码的第一行为`"ui";`既可并使用activity代替。
* `activity` UI模式下会启动一个Activity来运行脚本并在UI线程下运行。可通过该变量来获取该activity。
###五、在脚本中调用Java
使用importClass来引入要使用的库例如:
```javascript
importClass("android.view.View.OnClickListener")

View File

@@ -1,9 +1,11 @@
click 点击
longClick 长按
scrollUp 上滑
scrollDown 下滑
toast 提示
launch 运行
launchApp 运行应用
select 选择
input 输入
sleep 暂停运行
sleep 暂停运行
notStopped 非暂停

View File

@@ -30,5 +30,11 @@
<copyright>Copyright (c) 2015 zzhoujay</copyright>
<license>MIT License</license>
</notice>
<notice>
<name>Alipay ZeroSdk</name>
<copyright>Copyright 2016 Fung Go (fython)</copyright>
<url>https://github.com/fython/AlipayZeroSdk</url>
<license>Apache Software License 2.0</license>
</notice>
</notices>

View File

@@ -51,17 +51,16 @@
<string name="text_email">邮箱</string>
<string name="my_github">https://github.com/hyb1996/NoRootScriptDroid</string>
<string name="share_app">[免Root脚本机器人]下载地址https://github.com/hyb1996/NoRootScriptDroid/releases</string>
<string name="text_assist_service">点击定位辅助服务</string>
<string name="text_assist_serivce_notification">通知栏显示点击定位开关</string>
<string name="text_assist_service_notification">通知栏显示点击定位开关</string>
<string name="text_assist_service">点击区域辅助服务</string>
<string name="text_assist_service_notification">通知栏点击区域辅助开关</string>
<string name="text_others">其他</string>
<string name="text_assist_mode_enabled">点击定位辅助服务已开启(点击关闭)</string>
<string name="text_assist_mode_disabled">点击定位辅助服务已关闭(点击开启)</string>
<string name="text_assist_mode_enabled">点击区域辅助服务已开启(点击关闭)</string>
<string name="text_assist_mode_disabled">点击区域辅助服务已关闭(点击开启)</string>
<string name="text_error_report">错误报告</string>
<string name="text_sample_hello_big_sister">大姐姐好</string>
<string name="text_sample_qq_hongbao">示例QQ自动抢红包</string>
<string name="text_press_again_to_exit">再按一次退出程序</string>
<string name="text_function">函数</string>
<string name="sorry_for_crash">\"很抱歉程序遇到未知错误,即将停止运行\\n错误代码\"</string>
<string name="text_common_function">常用函数</string>
<string name="sorry_for_crash">很抱歉(ಥ _ ಥ)程序遇到未知错误,即将停止运行\n错误代码</string>
<string name="text_no_running_script">没有正在运行的脚本</string>
<string name="text_already_stop_n_scripts">已停止%d个正在运行的脚本</string>
<string name="text_start_running">开始运行</string>
@@ -85,4 +84,13 @@
<string name="text_choose_email_app">请选择邮件应用</string>
<string name="text_assist_clip">点击定位剪贴板</string>
<string name="text_script_stopped">脚本已停止</string>
<string name="assist_mode_notice">\"点击区域辅助服务\"是在要点击的区域不是文本时使用的,参见\"语法与API\"。\"点击区域辅助服务\"只有在\"自动操作服务\"开启时才有效。</string>
<string name="text_please_choose">请选择</string>
<string name="text_crash">崩溃了o(≧口≦)o</string>
<string name="crash_feedback">点击\"退出\"退出程序(ಥ _ ಥ)或者复制调试信息反馈给开发者(≧∇≦)ノ</string>
<string name="text_cannot_create_dialog_when_app_invisible">无法在后台显示弹框,脚本已停止运行</string>
<string name="text_sample_for_qq_chat">示例QQ强制聊天</string>
<string name="text_re_import_samples">重新导入示例脚本文件</string>
<string name="text_re_import_succeed">导入成功,重新打开应用生效</string>
<string name="text_fail">失败</string>
</resources>

View File

@@ -1,6 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceCategory
android:title="@string/text_others">
<Preference
android:title="@string/text_re_import_samples"/>
</PreferenceCategory>
<PreferenceCategory
android:title="@string/text_about">