首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Python MSS屏幕捕获目标特定窗口

Python MSS屏幕捕获目标特定窗口
EN

Stack Overflow用户
提问于 2021-08-19 04:50:59
回答 1查看 996关注 0票数 1

有没有办法从窗口句柄中截取特定的窗口?即使窗口在后台,它仍然会捕捉到它。目前我只有这个代码来记录全屏桌面,而不是在特定的窗口中。

代码语言:javascript
运行
复制
def window_capture():
    # Define your Monitor
    x = 0
    y = 0
    w = 1920
    h = 1080
    
    hwnd = None

    with mss.mss() as sct:
        # Part of the screen to capture
        monitor = {"left": x, "top": y, "width": w, "height": h}
        img = sct.grab(monitor)
        img = np.array(img)
    return img



while "Screen capturing":
    # Define Time
    last_time = time()

    # Get the img
    screenshot = window_capture()

    # Display the picture
    cv.imshow('Computer Vision', screenshot)

    print(f'FPS {(1 / (time() - last_time))}')

    # Press "q" to quit
    if cv.waitKey(1) == ord("q"):
        cv.destroyAllWindows()
        break
EN

回答 1

Stack Overflow用户

发布于 2021-08-20 16:12:45

嗨,我正在寻找和你一样的答案,看起来mss不能这样做。

如何做到这一点的可能方法是使用win32api。

检查这个:Fastest way to take a screenshot with python on windows

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/68842206

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档