Skip to content

Commit 052669a

Browse files
authored
Update README.md
1 parent 41fd834 commit 052669a

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

README.md

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,25 @@ d.swipe(x1, y1, x2, y2, spped)
375375
d.swipe(600, 2600, 600, 1200, speed=2000) # 上滑
376376
d.swipe(0.5, 0.8, 0.5, 0.4, speed=2000)
377377
```
378-
参数`x1`, `y1`表示滑动的起始点,`x2`, `y2`表示滑动的终点,`speed`为滑动速率, 范围:200~40000, 不在范围内设为默认值为2000, 单位: 像素点/秒
378+
- `x1`, `y1`表示滑动的起始点,`x2`, `y2`表示滑动的终点
379+
- `speed`为滑动速率, 范围:200~40000, 不在范围内设为默认值为2000, 单位: 像素点/秒
380+
381+
#### 滑动 ext
382+
```python
383+
384+
d.swipe_ext("up") # 向上滑动,"left", "right", "up", "down"
385+
d.swipe_ext("right", scale=0.8) # 向右滑动,滑动距离为屏幕宽度的80%
386+
d.swipe_ext("up", box=(0.2, 0.2, 0.8, 0.8)) # 在屏幕 (0.2, 0.2) -> (0.8, 0.8) 这个区域上滑
387+
388+
# 使用枚举作为参数
389+
from hmdriver2.proto import SwipeDirection
390+
d.swipe_ext(SwipeDirection.DOWN) # 向下滑动
391+
```
392+
- `direction`表示滑动方向,可以为`up`, `down`, `left`, `right`, 也可以为`SwipeDirection`的枚举值
393+
- `scale`表示滑动距离百分比,范围:0.1~1.0, 默认值为0.8
394+
- `box`表示滑动区域,格式为`(x1, y1, x2, y2)`, 表示滑动区域的左上角和右下角的坐标,可以为绝对坐标值,也可以为相当坐标(屏幕百分比)
395+
396+
Notes: `swipe_ext``swipe`的区别在于swipe_ext可以指定滑动区域,并且可以指定滑动方向,更简洁灵活
379397

380398
#### 输入
381399
```python
@@ -645,4 +663,4 @@ See [DEVELOP.md](/docs/DEVELOP.md)
645663
- https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/ut-V5
646664
- https://github.com/codematrixer/awesome-hdc
647665
- https://github.com/openatx/uiautomator2
648-
- https://github.com/mrx1203/hmdriver
666+
- https://github.com/mrx1203/hmdriver

0 commit comments

Comments
 (0)