python realizes the specific operation of automatic clicking in general games

  • 2021-12-09 09:18:33
  • OfStack

Required software:

pycharm (pycharm Installation Steps) Sandbox software, such as: sandbox (Baidu search installs itself, leave a message if necessary), 360 isolated sandbox Your game

Specific operation:

Open desktop games using sandbox software Open pycharm software and copy the following code. Right-click Run to run Back to the game, put the mouse on the top left corner of the button, waiting for the output of X=, Y=, when moving the mouse to the lower right corner of the button The game can be automatic

The code is as follows:


import random
import pyautogui
import time

time.sleep(3)
lupX, lupY = pyautogui.position()  #  Get the coordinate value of the upper left corner of the game button 
print(f'X={lupX},Y={lupY}')
time.sleep(2)  #  Wait 2s
rdownX, rdownY = pyautogui.position()  #  Get the coordinate value of the lower right corner of the game button 
print(f'X1={rdownX},Y1={rdownY}')

while True:
    x = random.randint(lupX, rdownX)  #  Take a random value, in the lupx And rdownx Between, the same below 
    y = random.randint(lupY, rdownY)
    pyautogui.click(x=x, y=y, duration=0.5)  #  Mouse click x,y
    time.sleep(1.5)  #  Delay 1.5s  You can modify it yourself 



Related articles: