Use python simulate mouse clicks automate work, increase your productivity!

Nothing could make learning to apply their knowledge to become more than the power.

I do not know if you are not at work some work to repeat the click of a mouse, as it will affect the relationship between the financial statements of statistics, we have to modify the end of each month in the ERP document date, documents and more time will allow you to modify the light point the mouse hand numb. (Click here to Tucao sand waves software, other documents can make bulk edits date, is this shift warehouse receipts not, how you developed so lazy? Such a point the rest of the work is not complete his?) Colleagues have mentioned to me before over the keyboard wizard, because it was responsible for other work, I have not been to understand. Now the company reduced staff, which work on me again, and when I learned just before Lianliankan, knowing Python simulate mouse clicks can be achieved, it would direct spend chant.

Let's look at pyautogui.

pyautogui.moveTo, move the mouse; pyautogui.click, clicking the mouse, to control the left click button, or by right-clicking, click = n the number of clicks is provided, with the click time interval The control, some programs have confirmed that a double click interval, If you do not add this interval, it is really no way to identify. (Ok, here's what you say, waves of sand. The first single at least you are not identified. I did less harm test.) On these two functions for my this operation is already good enough. Of course, the role of Pyautogui certainly more than that, pyautogui.typewrite can input keyboard letters numbers and some symbols, screenshot screen shot (this is also the time to achieve Lianliankan that can use oh.), Etc., may be interested to learn of your mother a bit. We know how analog control mouse, gotta tell it to go, where click on it. Pyautogui with pixel position to tell the program to be operated. Then how do we get this pixel it? Here, I use the Paint program that comes with the operating system. Paint inside the "Select" This feature will show a pixel area we choose, we just need to click from the position we have been elected to the top left corner of it.

Well, here everything is ready, the bar code.

# The Python group study 592 539 176 
Import pyautogui 

for I in Range (2,11 ): 

 0.5 seconds to move the cursor ( 400, 175 + 20 is I * ) position 

pyautogui.moveTo ( 400,175 * + I 20 is, DURATION = 0.5 ) 

pyautogui.click (clicks = 2, Button = ' left ' , interval The = 0.05) # click to open the document 

 the time.sleep ( . 3 ) 

 pyautogui.click ( 100, 140) # click edit 

 the time.sleep ( . 3 ) 

 pyautogui.click ( 350,190, Button = ' left ' ) # left-click the date of shipment

 pyautogui.click ( 350,190, Button = ' right ' ) # Right-click the delivery date 

 the time.sleep ( for 1.5 ) 

 pyautogui.click ( 595,397) # selected date. 5 

 the time.sleep ( for 1.5 ) 

 pyautogui.click ( 815,472) # complete 

 time. SLEEP ( 1.5 ) 

 pyautogui.click ( 565,425) # issue date is greater than the received date, is 

 the time.sleep ( 1.5 ) 

 pyautogui.click ( 155,140) # click save 

 the time.sleep ( 2 ) 

 pyautogui.click ( 432,140) # click queries

 time.sleep(5)

 

I have here a for loop is to let him begin operation from the first single, a single operation in the end of this page. Time.sleep Well, this system takes time to run, we let the mouse rest. Finally, there may be a need to remind you of the place is, if the program went to the half, found no need to perform any longer, or there are mistakes (such as system stuck the rest of the set is not enough), want to stop the program, this time CTRL + C is not acceptable. You need to put your mouse over the top left corner of the screen. Click generally stops after a few seconds down, (python shell will complain, not this tube) As for the effect Well, there is not record a motion picture, after all, is the leak of personal and corporate information. It is certainly an effective pro-test, in my time to rest for half an hour as collateral.

Guess you like

Origin www.cnblogs.com/chengxyuan/p/12146373.html