推荐学习书目
› Learn Python the Hard Way
Python Sites
› PyPI - Python Package Index
› http://diveintopython.org/toc/index.html
› Pocoo
值得关注的项目
› PyPy
› Celery
› Jinja2
› Read the Docs
› gevent
› pyenv
› virtualenv
› Stackless Python
› Beautiful Soup
› 结巴中文分词
› Green Unicorn
› Sentry
› Shovel
› Pyflakes
› pytest
Python 编程
› pep8 Checker
Styles
› PEP 8
› Google Python Style Guide
› Code Style from The Hitchhiker's Guide
wyds591101
V2EX  ›  Python

Windows 锁屏下,怎么通过 Python 截图运行桌面

  •  
  •   wyds591101 · Jan 18, 2022 · 5051 views
  •   You need to sign in to view this topic
    This topic created in 1768 days ago, the information mentioned may be changed or developed.

    跟各位大佬请求一个问题。

    我现在有一个需求是,通过 Python 进行 windows 的全屏截图,但是 Windows 的屏幕是处于锁定状态的。

    现在测试,通过 Windows 的 user32 调用的话,直接调用截图功能,只能截取到锁屏的图片,但是通过句柄的方式截图,就只能截取到对应句柄的,还是没有办法截取到运行桌面的截图。

    请教:我应该通过什么样的方式截图,才可以在锁屏的情况下,截取到我运行桌面的图片,谢谢。

    15 replies  •  2022-02-06 22:49:37 +08:00
    icepie
    icepie
    Jan 18, 2022
    1
    先 rdp 进入桌面截屏?
    ysc3839
    ysc3839
    Jan 18, 2022
    2
    应该没办法,应该是只能截到“当前桌面”的图,锁屏时“当前桌面”是锁屏界面,截不到其他桌面的图。
    wyds591101
    wyds591101
    OP
    Jan 18, 2022
    3
    @icepie 脚本运行的时候,没有连接。还是大佬指定是 python 自己写 rdp 连接进去去截图
    wyds591101
    wyds591101
    OP
    Jan 18, 2022
    4
    @ysc3839 我当前的状态是这样的,锁屏后截图截取到的是当前桌面。
    icepie
    icepie
    Jan 18, 2022
    5
    @wyds591101 我的想法是以当前用户 rdp 登陆进去截图 不知道可信不
    wyds591101
    wyds591101
    OP
    Jan 18, 2022
    6
    @icepie 本机运行 rdp 远程到本机,觉得会有问题,还没有找到 python3 的 rdp 包,找到了一个 py2 的
    ch2
    ch2
    Jan 18, 2022
    7
    没有用户 session 就没有桌面
    wyds591101
    wyds591101
    OP
    Jan 18, 2022
    8
    @ch2 大佬有解决方案吗
    minami
    minami
    Jan 18, 2022
    9
    注册成服务,然后用 Desktop Duplication 接口截屏
    wyds591101
    wyds591101
    OP
    Jan 18, 2022
    10
    @minami 收到,谢谢,我研究下。
    kakalongcn
    kakalongcn
    Jan 19, 2022
    11
    是云服务器吗?如果是阿里云或者腾讯云,可以通过服务商提供的网页版管理后台登录服务器,运行你的程序,然后再退出远程登录。另外,用向日葵远程登录也可以达到类似效果。
    wyds591101
    wyds591101
    OP
    Jan 19, 2022
    12
    @minami 我没成功,我使用的是 d3dshot
    wyds591101
    wyds591101
    OP
    Jan 19, 2022
    13
    @kakalongcn 不是的,是本地的电脑,默认不远程不使用向日葵 /todesk/tv 之类的
    icespace
    icespace
    Feb 3, 2022
    14
    采用 vnc 控制,桌面设成布自动锁屏,否则没有办法。windows 在锁屏时候布给你渲染桌面,你拿啥都抓不到,因为根本没有
    wyds591101
    wyds591101
    OP
    Feb 6, 2022
    15
    @icespace 嗯 确实什么都没有。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   2049 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 41ms · UTC 03:58 · PVG 11:58 · LAX 19:58 · JFK 22:58
    ♥ Do have faith in what you're doing.