python辅助QQ登入
import pyautogui
import time
import random
from pyautogui import ImageNotFoundException
# 生成随机等待时间,范围在1到3秒之间
random_time = random.uniform(1, 3)
def find_and_click(image_path, move=False, execute_next=True):
try:
image_location = pyautogui.locateOnScreen(image_path, grayscale=True, confidence=0.8)
if image_location:
position = pyautogui.center(image_location)
if move:
pyautogui.moveTo(position, duration=0.5) #移动
pyautogui.moveRel(30, 0, 0.1) #向右移动30
pyautogui.doubleClick() #双击
if not execute_next:
return # 如果不执行后续语句,则直接返回
pyautogui.doubleClick(position, duration=0.3)
time.sleep(random_time)
else:
print(f"未找到指定的图片: {image_path}")
except ImageNotFoundException:
print(f"图片未找到,程序出现异常: {image_path}")
# 循环执行 7 次
for _ in range(7):
find_and_click('.\\images\\qq_login.bmp')
find_and_click('.\\images\\login.bmp')
find_and_click('.\\images\\qx.bmp', move=True, execute_next=False)
需要的图片