首页
归档
笔记
树洞
搜索
友言

文章详情

Interesting People Record Interesting.

/ Python / 文章详情

python PC端自动化萌新实战笔记

Sonder
2天前
979字
2分钟
浏览 (10)

别踩白块了

https://www.4399.com/flash/154247_3.htm

复制代码
import pyautogui
import time

# 鼠标移动到最左上角停止运行
pyautogui.FAILSAFE = True

def start():
   time.sleep(3)
   # 获取当前屏幕分辨率
   # screenWidth, screenHeight = pyautogui.size()
   # pyautogui.moveTo(x=100, y=100, duration=2, tween=pyautogui.linear)
   # 鼠标移到屏幕中央。
   # pyautogui.moveTo(130, 26)
   # img = pyautogui.screenshot()
   # res = img.getpixel((970,399))
   # print("文件名:auto.py, 行数:14, 参数是:res", res)
   item_box_bottom = 605 # 每个盒子的底部
   x_start = 970 # x轴最左侧
   x_end = 1284 # x轴最右边
   while True:
       img = pyautogui.screenshot() # 截图当前屏幕
       for i in range(x_start, x_end, 100):
           # 获取当前区域的颜色
           res = img.getpixel((i, item_box_bottom))
           print("文件名:auto.py, 行数:20, 参数是:res", res) # (2,2,2)
           if res[0] == 2:
               pyautogui.click(i, item_box_bottom)


if __name__ == '__main__':
   print(pyautogui.__version__)
   start()
下一篇 / 尤雨溪推荐的全新Vue动画库

🎯 相关文章

💡 推荐文章

🕵️‍♂️ 评论 (0)