Python 的 pyautogui 写个简单 关闭广告 和 刷视频 程序
一、需要一个手机边电脑的工具
PyQtScrcpy下载
二、简单 关闭广告代码:
注:x,y 位置 可用 PixPin 软件来查看自己的位置
import pyautogui
import time
import subprocess
import sys # 新增导入
import random as Random
def dianji():
time.sleep(5)
pyautogui.moveTo(x=1318, y=83) #
pyautogui.click() # 点击关闭
time.sleep(1)
pyautogui.moveTo(x=1390, y=585) # 点击看另一个
pyautogui.click()
# 新增倒计时函数
def countdown(seconds):
for i in range(seconds, 0, -1):
sys.stdout.write(f"\r等待倒计时: {i} 秒 [{'■'*(seconds-i+1)}{'□'*(i-1)}]")
sys.stdout.flush()
time.sleep(1)
print() # 换行
# 循环 10 次,每次随机等待 50-55 秒,然后执行拖拽操作
for i in range(10):
ti = Random.randint(50, 55) # 生成 50 到 55 之间的随机整数
countdown(ti) # 调用倒计时函数
dianji() #
三、简单 刷视频 程序
注:start_x,start_y,end_x,end_y 位置 可用 PixPin 软件来查看自己的位置
import pyautogui
import time
import subprocess
import sys # 新增导入
import random as Random
def lookauto():
# 获取初始位置(比如文件图标位置)
start_x, start_y = 1480, 668
# 目标位置(比如文件夹位置)
end_x, end_y = 1481, 200
# 移动到起始位置
pyautogui.moveTo(start_x, start_y, duration=0.5)
# 按下鼠标
pyautogui.mouseDown(button='left')
# 移动到目标位置
pyautogui.moveTo(end_x, end_y, duration=1)
# 松开鼠标
pyautogui.mouseUp(button='left')
print("拖拽操作完成")
# 新增倒计时函数
def countdown(seconds):
for i in range(seconds, 0, -1):
sys.stdout.write(f"\r等待倒计时: {i} 秒 [{'■'*(seconds-i+1)}{'□'*(i-1)}]")
sys.stdout.flush()
time.sleep(1)
print() # 换行
# 循环 30 次,每次随机等待 10-60 秒,然后执行拖拽操作
for i in range(30):
ti = Random.randint(10, 60) # 生成 10 到 60 之间的随机整数
countdown(ti) # 调用倒计时函数
lookauto() # 调用拖拽函数