How to use PyAutoGUI for calculation
This article is to share with you about how to use PyAutoGUI for calculation, the editor thinks it is very practical, so I share it with you to learn. I hope you can get something after reading this article.
Today, we use PyAutoGUI to operate windows's calculator for calculation. The principle is to call the method locateOnScreen (image) to find the location in the calculator and click the mouse, and then calculate the result. Say no more. Let's get started:
First of all, let's open the calculator in the windows operating system and save the screenshots of 1, 2, +, and = to a folder. This is called pyauto:
Next, write the execution code, which is very simple. Let's create a new file in this folder named
Py3_autocalc.py:
Import pyautogui
Pyautogui.click (pyautogui.locateOnScreen ('1.png')) pyautogui.click (pyautogui.locateOnScreen (' plus.png')) pyautogui.click (pyautogui.locateOnScreen ('2.png')) pyautogui.click (pyautogui.locateOnScreen (' equal.png'))
Open the cmd command in this folder to execute python py3_autocalc.py:
The above is how to use PyAutoGUI to calculate, the editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.