Buscar..


Introducción

pyautogui es un módulo usado para controlar el mouse y el teclado. Este módulo se usa básicamente para automatizar el clic del mouse y las tareas de pulsación del teclado. Para el mouse, las coordenadas de la pantalla (0,0) comienzan desde la esquina superior izquierda. Si está fuera de control, mueva rápidamente el cursor del mouse hacia la parte superior izquierda, tomará el control del mouse y el teclado del Python y se lo devolverá.

Funciones del mouse

Estas son algunas de las funciones útiles del mouse para controlar el mouse.

size()           #gave you the size of the screen
position()     #return current position of mouse
moveTo(200,0,duration=1.5)     #move the cursor  to (200,0) position  with 1.5 second delay     
moveRel()          #move the cursor relative to your current position.
click(337,46)           #it will click on the position mention there
dragRel()              #it will drag the mouse relative to position
pyautogui.displayMousePosition()     #gave you the current mouse position but should be done on terminal.

Funciones del teclado

Estas son algunas de las funciones útiles del teclado para automatizar la pulsación de teclas.

typewrite('')    #this will type the string on the screen where current window has focused.
typewrite(['a','b','left','left','X','Y'])
pyautogui.KEYBOARD_KEYS    #get the list of all the keyboard_keys.
pyautogui.hotkey('ctrl','o')    #for the combination of keys to enter.

ScreenShot y reconocimiento de imágenes

Esta función te ayudará a tomar la captura de pantalla y también a relacionar la imagen con la parte de la pantalla.

.screenshot('c:\\path')        #get the screenshot.
.locateOnScreen('c:\\path')    #search that image on screen and get the coordinates for you.
locateCenterOnScreen('c:\\path')       #get the coordinate for the image on screen.


Modified text is an extract of the original Stack Overflow Documentation
Licenciado bajo CC BY-SA 3.0
No afiliado a Stack Overflow