In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article introduces the relevant knowledge of "how to install and use PyAutoGUI". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
PyAutoGUI does not know if you have ever used it, it is a library that uses Python to automatically control the keyboard and mouse. But any work that you don't want to repeat manually can be solved with this library.
For example, I want to send a Wechat regularly in the middle of the night, or browse the page automatically every day, it can completely simulate manual operation, and you can browse the drama with peace of mind.
Well, laziness is a programmer's virtue.
Install pyautoguipip install pyautogui keyboard and mouse control > import pyautogui
> screenWidth, screenHeight = pyautogui.size () # returns the screen resolution
> currentMouseX, currentMouseY = pyautogui.position () # returns the location of the mouse
> pyautogui.moveTo (100150) # move the mouse to the specified location
> pyautogui.click () # Click
> pyautogui.click (200,220) # Click to specify a location
> pyautogui.move (None, 10) # move the mouse 10 pixels
> pyautogui.doubleClick () # double click the mouse
> pyautogui.write ('Hello worldview, interval=0.25) # enter a string with a residence time of 0.25 seconds for each character
> pyautogui.press ('esc') # exit key
> pyautogui.keyDown ('shift') # Shitf keyboard
Pyautogui.hotkey ('ctrl',' c') # key combination
Pyautogui can simulate all mouse and keyboard operations. Here is how to draw automatically with pyautogui.
Show message pop-up window
In addition to controlling the mouse and keyboard, you can also call the system pop-up window.
> 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'
Through the window message box, you can achieve some simple human-computer interaction, such as when you need to enter content manually in some places, you can accept the user's instructions.
Screenshot
The screenshot is realized by using the Pillow module. The use of the screenshot is to identify the content of the picture through the image recognition technology, and then accurately locate the location of an element through the content to achieve accurate click.
> import pyautogui
> > im1 = pyautogui.screenshot ()
> im1.save ('my_screenshot.png')
> im2 = pyautogui.screenshot ('my_screenshot2.png')
This is the end of the content of "how to install and use PyAutoGUI". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.