[-002-]-Python3+Unittest+Uiautomation Windows桌面App UI自动化之鼠标操作

1、单击鼠标左键

Click(x: int, y: int, waitTime: float = OPERATION_WAIT_TIME)

模拟鼠标在点 x, y 的点击。

OPERATION_WAIT_TIME默认为0.5

即等待时间默认为0.5秒

2、单击鼠标中键

MiddleClick(x: int, y: int, waitTime: float = OPERATION_WAIT_TIME)

模拟鼠标在点 x, y 的点击。

OPERATION_WAIT_TIME默认为0.5

即等待时间默认为0.5秒

3、单机鼠标中键

MiddleClick(x: int, y: int, waitTime: float = OPERATION_WAIT_TIME)

4、单机鼠标右键

RightClick(x: int, y: int, waitTime: float = OPERATION_WAIT_TIME)

5、按鼠标左键

PressMouse(x: int, y: int, waitTime: float = OPERATION_WAIT_TIME)

6、释放鼠标左键

ReleaseMouse(waitTime: float = OPERATION_WAIT_TIME)

按鼠标中键与右键,释放鼠标中键与右键

RightPressMouse()、RightReleaseMouse()
MiddlePressMouse()、MiddleReleaseMouse()

7、鼠标移动

MoveTo(x: int, y: int, moveSpeed: float = 1, waitTime: float = OPERATION_WAIT_TIME)

模拟鼠标从当前光标移动到点 x, y。

moveSpeed:1 正常速度,< 1 移动速度较慢,> 1 移动速度更快。

8、鼠标左键拖放

DragDrop(x1: int, y1: int, x2: int, y2: int, moveSpeed: float = 1, waitTime: float = OPERATION_WAIT_TIME)

模拟鼠标左键从点 x1、y1 拖放到点 x2、y2。 

moveSpeed:1 正常速度,< 1 移动速度较慢,> 1 移动速度更快。

9、鼠标右键拖放

RightDragDrop(x1: int, y1: int, x2: int, y2: int, moveSpeed: float = 1, waitTime: float = OPERATION_WAIT_TIME)

模拟鼠标右键从点 x1、y1 拖放到点 x2、y2。 

moveSpeed:1 正常速度,< 1 移动速度较慢,> 1 移动速度更快。

鼠标中键拖放使用MiddleDragDrop()

 

10、鼠标滚轮向下

WheelDown(wheelTimes: int = 1, interval: float = 0.05, waitTime: float = OPERATION_WAIT_TIME)

模拟鼠标滚轮向下。 

wheelTimes:轮次,默认为1
interval: 间隔,默认为0.05
waitTime: 等待时间,默认为0.5

11、鼠标滚轮向上 

WheelUp(wheelTimes: int = 1, interval: float = 0.05, waitTime: float = OPERATION_WAIT_TIME)

12、获取屏幕尺寸
GetScreenSize()

 

13、确定窗口是否最小化

IsZoomed(handle: int) -> bool

14、桌面是否被锁

IsDesktopLocked() -> bool

 




posted @ 2023-06-15 11:49  旅行没有终点  阅读(289)  评论(0编辑  收藏  举报