python PyAutoGUI 模拟鼠标键盘操作和截屏
简介
一款跨平台/无依赖的自动化测试工具,目测只能控制鼠标/键盘/获取屏幕尺寸/弹出消息框/截屏。
安装
pip install pyautogui
鼠标键盘控制
>>> import pyautogui>>> screenWidth, screenHeight = pyautogui.size()>>> currentMouseX, currentMouseY = pyautogui.position()>>> pyautogui.moveTo(100, 150)>>> pyautogui.click()>>> pyautogui.moveRel(None, 10) # move mouse 10 pixels down>>> pyautogui.doubleClick()>>> pyautogui.moveTo(500, 500, duration=2, tween=pyautogui.tweens.easeInOutQuad) # use tweening/easing function to move mouse over 2 seconds.>>> pyautogui.typewrite('Hello world!', interval=0.25) # type with quarter-second pause in between each key>>> pyautogui.press('esc')>>> pyautogui.keyDown('shift')>>> pyautogui.typewrite(['left', 'left', 'left', 'left', 'left', 'left'])>>> pyautogui.keyUp('shift')>>> pyautogui.hotkey('ctrl', 'c')
显示消息弹出框
>>> import pyautogui>>> pyautogui.alert('This is an alert box.')'OK'>>> pyautogui.confirm('Shall I proceed?')'Cancel'>>> pyautogui.confirm('Enter option.', buttons=['A', 'B', 'C'])'B'>>> pyautogui.prompt('What is your name?')'Al'>>> pyautogui.password('Enter password (text will be hidden)')'swordfish'
截屏
>>> import pyautogui>>> im1 = pyautogui.screenshot()>>> im1.save('my_screenshot.png')>>> im2 = pyautogui.screenshot('my_screenshot2.png')
定位截屏
>>> import pyautogui>>> button7location = pyautogui.locateOnScreen('button.png') # returns (left, top, width, height) of matching region>>> button7location(1416, 562, 50, 41)>>> buttonx, buttony = pyautogui.center(button7location)>>> buttonx, buttony(1441, 582)>>> pyautogui.click(buttonx, buttony) # clicks the center of where the button was found
参考
http://pyautogui.readthedocs.io/en/latest/index.html
https://github.com/asweigart/pyautogui
https://github.com/asweigart/sushigoroundbot
python PyAutoGUI 模拟鼠标键盘操作和截屏相关推荐
- python截图工具和模拟鼠标键盘_python PyAutoGUI 模拟鼠标键盘操作和截屏功能
简介 一款跨平台/无依赖的自动化测试工具,目测只能控制鼠标/键盘/获取屏幕尺寸/弹出消息框/截屏. 安装 pip install pyautogui 鼠标键盘控制 >>> impor ...
- python --pyautogui(模拟鼠标键盘操作)
安装 pip install pyautogui 官网 https://pyautogui.readthedocs.io/en/latest/ 参考文章1 参考文章2 详解 自动防故障 pyautog ...
- PyMouse模拟鼠标键盘操作
PyMouse模拟鼠标键盘操作 使用PyMouse实现模拟鼠标键盘操作 -----解决方案1 1)安装[pyMouse]( https://pypi.org/project/PyMouse/) 2)安 ...
- C# 模拟 鼠标 键盘操作
C# 模拟 鼠标 键盘操作 转载于:https://www.cnblogs.com/macT/p/10208222.html
- 模拟鼠标键盘操作,含硬件模拟技术。[转]
模拟鼠标键盘操作,含硬件模拟技术. 键盘是我们使用计算机的一个很重要的输入设备了,即使在鼠标大行其道的今天,很多程序依然离不开键盘来操作.但是有时候,一些重复性的,很繁琐的键盘操作总会让人疲惫,于是就 ...
- 效率提升:使用AppleScript模拟鼠标键盘操作制作自动化工具
文章目录 前言 AppleScript的实践应用 实践:还原修饰键默认设置 AppleScript基础知识 1.基本模块 语法 变量和属性 类型转换 运算符 List(数组) Record(键值对) ...
- python模拟鼠标键盘操作_人生苦短我用Python——模拟鼠标点击和键盘输入的操作...
通过Python可以模拟鼠标点击和键盘输入的操作,进而可以实现一些比较有趣的功能,例如游戏挂机.自动发消息等. 本文以自动发消息为例,实现该功能,通过该代码可以自动往QQ.微信发送任意内容.首先考虑想 ...
- python模拟按键包_今天玩点啥:利用python之PyUserInput实现模拟鼠标键盘操作,抢红包?聊天?自动下载?...
一.PyUserInput安装 python3.5的PyMouse和PyKeyboard模块都集成到了PyUserInput模块中.在python3.5中,直接安装PyUserInput模块即可 Py ...
- python模拟鼠标键盘操作_python3实现复制粘贴 Python-模拟鼠标键盘动作 | 猴头客
1. 安装pyperclip pip install pyperclip 使用方法 复制 pyperclip.copy("hello world") 粘贴 pyperclip.pa ...
最新文章
- 用java数组模拟登录和注册功能
- 【CodeForces - 349C】Mafia(思维模拟,优秀的二分)
- 【操作系统】—操作系统的四个特征
- davlik虚拟机内存管理之一——内存分配
- 【剑指offer】(七)—— 用两个栈实现队列
- DB2with的定义与用法
- 打标工具labelme或者labelimg遇到图片闪退的完美解决方案
- 动态显示姓名--汇编语言版
- 将中划线转为驼峰式写法
- 教你把mov格式的视频转换mp4
- 一小时教会你用JAVA制作超级玛丽小游戏
- 基于微信小程序的自习室预约系统设计与实现-计算机毕业设计源码+LW文档
- 专访 | 刘嘉松:开源,互惠且共赢
- dellR730ch插拔sdka
- 项目研发,有哪些好用的免费脑图工具软件
- VTS manifest xml
- 【Cadence Virtuoso】IC617 入门操作 (MOS特性分析)
- 用于电子书的RSS——OPDS
- 安装VMware-tools出现initctl: Job failed to start
- 最重要的会计期间是_数据备份应该在每个会计期间完成( )后进行
热门文章
- 华硕ASUS RT-AC66U无线路由器部署NTP Server最佳实践
- 将条码软件中的标签转化成PDF
- Fourier Neural Operator for Parametric Partial Differential Equations
- Kanzi 记录:界面整体介绍(一),自己理解,绝非生搬硬套。
- 山东大学软件工程期末复习知识点总结
- 【品牌DTC增长力】私域,你做的可能是“假的”
- PS绘画效果滤镜Snap Art 4
- 【概率论】贝叶斯法则
- win10无法登录(调用的对象已与其客户端断开连接)
- 计算机毕业设计Java城市智能公交系统(源码+系统+mysql数据库+lw文档)