Skip to content

Commit

Permalink
docs: 补齐一些代码块的语言类型
Browse files Browse the repository at this point in the history
  • Loading branch information
xxxxue committed Aug 13, 2022
1 parent 5a591b4 commit ec0fa30
Show file tree
Hide file tree
Showing 13 changed files with 155 additions and 160 deletions.
29 changes: 13 additions & 16 deletions console.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ console模块中的一些函数也可以直接作为全局函数使用,例如l
* `autoHide` {boolean} 是否自动隐藏,默认false当程序结束的时候是否自动隐藏控制
显示控制台。这会显示一个控制台的悬浮窗(需要悬浮窗权限)。

``` js
```js
console.show(true); //程序结束自动 隐藏控制台
console.show(); //结束不会自动隐藏控制台
```
Expand All @@ -32,7 +32,7 @@ console.show(); //结束不会自动隐藏控制台

打印到控制台,并带上换行符。 可以传入多个参数,第一个参数作为主要信息,其他参数作为类似于 [printf(3)](http://man7.org/linux/man-pages/man3/printf.3.html) 中的代替值(参数都会传给 util.format())。

``` js
```js
const count = 5;
console.log('count: %d', count);
// 打印: count: 5 到 stdout
Expand Down Expand Up @@ -74,7 +74,7 @@ console.log('count:', count);

断言。如果value为false则输出错误信息message并停止脚本运行。

``` js
```js
var a = 1 + 1;
console.assert(a == 2, "加法出错啦");
```
Expand Down Expand Up @@ -126,7 +126,7 @@ console.trace('Show me');
**部分机型可能会有控制台不显示输入框的情况,属于bug。**

例如:
``` js
```js
var n = console.input("请输入一个数字:");
//输入123之后:
toast(n + 1);
Expand All @@ -142,7 +142,7 @@ toast(n + 1);
部分机型可能会有控制台不显示输入框的情况,属于bug。

例如:
```
```js
var n = console.rawInput("请输入一个数字:");
//输入123之后:
toast(n + 1);
Expand All @@ -166,7 +166,7 @@ console.setSize(device.width / 2, device.height / 2);

设置控制台的位置,单位像素。

```
```js
console.show();
console.setPosition(100, 100);
```
Expand All @@ -181,7 +181,7 @@ console.setPosition(100, 100);
* `filePattern` {string} 日志写入格式,参见[PatternLayout](http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/PatternLayout.html)

设置日志保存的路径和配置。例如把日志保存到"/sdcard/1.txt":
``` js
```js
console.setGlobalLogConfig({
"file": "/sdcard/1.txt"
});
Expand All @@ -203,7 +203,7 @@ console.setGlobalLogConfig({
设置标题名称,字体颜色,标题栏高度


``` js
```js
console.setTitle("中文","#ff11ee00",30);
console.setTitle("中文");
console.setTitle("中文","#ff11ee00");
Expand All @@ -217,7 +217,7 @@ console.setTitle("中文","#ff11ee00");

**需要在显示控制台之后才能设置,否则空指针**

``` js
```js

function myrandom(min,max){
return Math.floor(Math.random() * (max - min + 1) ) + min;
Expand Down Expand Up @@ -249,9 +249,8 @@ threads.start(function () {
控制 console 是否可以输入文字


``` js
```js
console.setCanInput(false);

```

## console.setBackgroud(color)
Expand All @@ -261,9 +260,8 @@ console.setCanInput(false);

**需要在显示控制台之后才能设置,否则空指针**

``` js
```js
console.setBackgroud("#33ef0000");

```

## console.setMaxLines(maxLines);
Expand All @@ -272,9 +270,8 @@ console.setBackgroud("#33ef0000");
设置 console 显示最大行数,默认-1,不限 ,超出行数系统会清空,从0开始显示
不限制,显示列表过长,android内存又不足,系统会回收console的引用,即console 将不显示。

``` js
console.setMaxLines(500);

```js
console.setMaxLines(500);
```


Expand Down
18 changes: 9 additions & 9 deletions coordinatesBasedAutomation.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
基于坐标的脚本通常会有分辨率的问题,这时可以通过`setScreenMetrics()`函数来进行自动坐标放缩。这个函数会影响本章节的所有点击、长按、滑动等函数。通过设定脚本设计时的分辨率,使得脚本在其他分辨率下自动放缩坐标。

控件和坐标也可以相互结合。一些控件是无法点击的(clickable为false), 无法通过`.click()`函数来点击,这时如果安卓版本在7.0以上或者有root权限,就可以通过以下方式来点击:
```
```js
//获取这个控件
var widget = id("xxx").findOne();
//获取其中心位置并点击
Expand All @@ -26,7 +26,7 @@ click(widget.bounds().centerX(), widget.bounds().centerY());
设置脚本坐标点击所适合的屏幕宽高。如果脚本运行时,屏幕宽度不一致会自动放缩坐标。

例如在1920*1080的设备中,某个操作的代码为
```
```js
setScreenMetrics(1080, 1920);
click(800, 200);
longClick(300, 500);
Expand Down Expand Up @@ -70,7 +70,7 @@ longClick(300, 500);
一般而言,只有按住过程中被其他事件中断才会操作失败。

一个连点器的例子如下:
```
```js
//循环100次
for(var i = 0; i < 100; i++){
//点击位置(500, 1000), 每次用时1毫秒
Expand Down Expand Up @@ -102,7 +102,7 @@ for(var i = 0; i < 100; i++){
同时模拟多个手势。每个手势的参数为\[delay, duration, 坐标\], delay为延迟多久(毫秒)才执行该手势;duration为手势执行时长;坐标为手势经过的点的坐标。其中delay参数可以省略,默认为0。

例如手指捏合:
```
```js
gestures([0, 500, [800, 300], [500, 1000]],
[0, 500, [300, 1500], [500, 1000]]);
```
Expand All @@ -114,7 +114,7 @@ gestures([0, 500, [800, 300], [500, 1000]],
RootAutomator是一个使用root权限来模拟触摸的对象,用它可以完成触摸与多点触摸,并且这些动作的执行没有延迟。

一个脚本中最好只存在一个RootAutomator,并且保证脚本结束退出他。可以在exit事件中退出RootAutomator,例如:
```
```js
var ra = new RootAutomator();
events.on('exit', function(){
ra.exit();
Expand All @@ -132,7 +132,7 @@ events.on('exit', function(){
* `id` {number} 多点触摸id,可选,默认为1,可以通过setDefaultId指定。

点击位置(x, y)。其中id是一个整数值,用于区分多点触摸,不同的id表示不同的"手指",例如:
```
```js
var ra = new RootAutomator();
//让"手指1"点击位置(100, 100)
ra.tap(100, 100, 1);
Expand Down Expand Up @@ -206,20 +206,20 @@ ra.exit();


例如:
```
```js
Tap(100, 100);
sleep(500);
```

注意,动作的执行可能无法被停止,例如:
```
```js
for(var i = 0; i < 100; i++){
Tap(100, 100);
}
```
这段代码执行后可能会出现在任务管理中停止脚本后点击仍然继续的情况。
因此,强烈建议在每个动作后加上延时:
```
```js
for(var i = 0; i < 100; i++){
Tap(100, 100);
sleep(500);
Expand Down
Loading

0 comments on commit ec0fa30

Please sign in to comment.