鼠标点击事件
今天线上年会、有个点弹幕的东西,但是我多懒啊、所以准备写个小功能来自动不停的点,因为我就在电脑旁边坐着看直播所以没有那么多判断
# 这是点击事件
from pymouse import PyMouse from time import sleep import random for i in range(0, 10000): #循环点击 m = PyMouse() m.click(3622, 948) ran = random.randint(4, 5) print(ran) sleep(ran) #每十秒点击一次
# 这是获取鼠标坐标值,这段代码搜到的、在这边做个记录
import pyautogui def get_cord_real_time(): """get mouse coordinate in real time""" print('mouse coordinate now: ') try: while 1: x, y = pyautogui.position() print_position = f'X: {str(x).rjust(5)}, Y: {str(y).rjust(5)}' print(f"\r{print_position}", end='', flush=True) except KeyboardInterrupt: print('\n') if __name__ == '__main__': get_cord_real_time()
Airtest自动化测试交流群:739857090