吾爱破解 - LCG - LSG |安卓破解|病毒分析|www.52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 873|回复: 13
收起左侧

[Python 原创] 屏幕固定区域等时间间隔截屏一次

  [复制链接]
zjg121 发表于 2024-4-4 06:37
启动程序,第二次点击鼠标确定区域的左上角位置,第三次点击鼠标确定区域的右下角位置,第四次点击确定下一页按钮的位置,等待5秒后,开始每秒截屏一次。
[Python] 纯文本查看 复制代码
from pynput import mouse
import pyautogui
from time import sleep



# 初始化一个空列表来存储点击的坐标
click_positions = []


def on_click(x, y, button, pressed):
    if pressed:
        print(f'Clicked at ({x}, {y}) with {button}')

        # 将点击的坐标添加到列表中
        click_positions.append((x, y))

        # 如果列表中有两个坐标,就不再记录更多
        if len(click_positions) == 4:
            # 停止监听
            return False

        # 开始监听鼠标事件


with mouse.Listener(on_click=on_click) as listener:
    listener.join()

# 打印前两次点击的坐标
if len(click_positions) == 4:
    print("First click position:", click_positions[0])
    print("Second click position:", click_positions[1])
    print("Third click position:", click_positions[2])
    print("Fourth click position:", click_positions[3])
else:
    print("Not enough clicks recorded.")
sleep(10)
for i in range(49):
    # 截取屏幕,参数为截屏区域的左上角坐标和宽高
    im = pyautogui.screenshot(region=(click_positions[1][0], click_positions[1][1], click_positions[2][0], click_positions[2][1]))

    # 保存截图到文件
    im.save(f'd:/a/截屏{str(i).zfill(3)}.png')
    sleep(1)
    # 鼠标左键点击指定坐标的位置,参数为坐标位置
    pyautogui.click(x=click_positions[3][0], y=click_positions[3][1])

免费评分

参与人数 3吾爱币 +3 热心值 +3 收起 理由
junjia215 + 1 + 1 热心回复!
rgyjc + 1 + 1 我很赞同!
jy138290 + 1 + 1 谢谢@Thanks!

查看全部评分

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

52zct 发表于 2024-4-4 10:40
求打包版本,我尝试打包,总是出现报错
[Asm] 纯文本查看 复制代码
raise Exception(f"Qt plugin directory '{plugin_src_dir}' does not exist!")
Exception: Qt plugin directory 'C:/Users/???/AppData/Local/Programs/Python/Python310/lib/site-packages/PyQt5/Qt5/plugins' does not exist!
linweite 发表于 2024-4-4 08:55
caogen666 发表于 2024-4-4 08:57
unicornTwo 发表于 2024-4-4 09:09
最喜欢代码分析
prccpc 发表于 2024-4-4 09:17
学习学习代码
鹿坪 发表于 2024-4-4 10:10
又学到了,谢谢分享
wyesheng 发表于 2024-4-4 13:16
水平不够,特地来学习学习,哈哈
q3520520 发表于 2024-4-4 13:34
我很赞同!
sihehe 发表于 2024-4-7 10:00
这个以前我也用python写过类似的功能,自动截图全屏,并将截图的文件发到企业微信机器人.
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则 警告:本版块禁止灌水或回复与主题无关内容,违者重罚!

快速回复 收藏帖子 返回列表 搜索

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2024-5-5 03:11

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表