Uploaded by Ahaan Shetty

Pyautogui

advertisement
PyAutoGUI
Introduction
•
PyAutoGUI is a cross-platform GUI automation Python module for human beings.
Used to programmatically control the mouse & keyboard.
•
PyAutoGUI lets your Python scripts control the mouse and keyboard to automate
interactions with other applications.
•
PyAutoGUI works on Windows, macOS, and Linux, and runs on Python 2 and 3.
Installation
PyAutoGUI is a project on the python foundation. Hence it can be installed simply using the pip
package manager.
Features
•
•
•
•
•
Moving the mouse and clicking or typing in the windows of other applications.
Sending keystrokes to applications (for example, to fill out forms).
Take screenshots, and given an image (for example, of a button or checkbox), find it
on the screen.
Locate an application’s window, and move, resize, maximize, minimize, or close it
(Windows-only, currently)
Display message boxes for user interaction while your GUI automation script runs.
Installing
Implementation
Opening calculator
Adding 2 numbers
pyautogui.press('escape', pause=pauseSeconds)
pyautogui.press('3', pause=pauseSeconds)
pyautogui.press('+', pause=pauseSeconds)
pyautogui.press('9', pause=pauseSeconds)
pyautogui.press('enter', pause=pauseSeconds)
Subtracting 2 numbers
pyautogui.press('escape', pause=pauseSeconds)
pyautogui.press('9', pause=pauseSeconds)
pyautogui.press('-', pause=pauseSeconds)
pyautogui.press('6', pause=pauseSeconds)
pyautogui.press('enter', pause=pauseSeconds)
Adding 2 decimal numbers
pyautogui.press('escape', pause=pauseSeconds)
pyautogui.press('3', pause=pauseSeconds)
pyautogui.moveTo(1183, 480)
pyautogui.click(pause=pauseSeconds)
pyautogui.press('7', pause=pauseSeconds)
pyautogui.press('+', pause=pauseSeconds)
pyautogui.press('5', pause=pauseSeconds)
pyautogui.moveTo(1183, 480)
pyautogui.click(pause=pauseSeconds)
pyautogui.press('3', pause=pauseSeconds)
To close the calculator
pyautogui.press('escape', pause=pauseSeconds)
pyautogui.hotkey('alt', 'f4')
Why use PyAutoGUI
•
Cross Platform: The software can work on any operating system that is
windows, Linux and mac OS.
•
•
It is a python package so can be used in any python code to test the system.
Cross System testing that is it can be used to test the web based and also
desktop based application.
•
Image Recognition for finding any value or image that matches the image
and give back the location of that image that matches the image.
THANK YOU
Download