import random import time import pyautogui class Collect: def __init__(self, target=(1935, 615)): self.target = target def get_all_target(self): for i in range(12): x = self.target[0] + 52 * i for j in range(5): y = self.target[1] + 52 * j yield x, y def __call__(self, *args, **kwargs): # 按下ctrl pyautogui.keyDown("ctrl") # hold down the shift key time.sleep(random.random()) for x, y in self.get_all_target(): pyautogui.moveTo(x, y, random.random() / 20) time.sleep(random.random() / 20) pyautogui.leftClick() time.sleep(random.random()) # 松开ctrl pyautogui.press("ctrl")