Python跨平台兼容多屏截图 [英] Python cross platform compatible multi screen screenshot

查看:63
本文介绍了Python跨平台兼容多屏截图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用的 Python 解释器:2.7(在 OSX 10.11 上使用 python3.5 py2app 时遇到问题

Python interpretor used: 2.7 (having trouble with python3.5 py2app on OSX 10.11

我正在使用 python 和 pygame 开发一个有趣的屏幕截图应用程序,但我被困在 1 个屏幕限制,因为 pygame 似乎并不隐式支持多个屏幕.

I am working on an interesting screenshot app using python and pygame but i am stuck at 1 screen limit since pygame doesn't seem to implicitly support multiple screens.

我的问题是现在我使用 pyautogui 屏幕截图功能来捕获整个屏幕,然后在 pygame 全屏窗口中打开它,我可以在其中修改图像等.

My problem is that right now I use pyautogui screenshot function to capture the whole screen and i open it in a pygame fullscreen window where i can modify the image and such.

我想知道是否有办法以跨平台兼容的方式一次对多个显示器进行截图.现在我还没有弄清楚如何使 pyautogui 屏幕截图除默认显示之外的任何其他显示

I would like to know if there is a way to screenshot multiple displays at once in a cross platform compatible way. Right now i have yet to figure out how to make pyautogui screenshot any other display other than the default one

推荐答案

您可能希望查看 pyscreenshot 库,它是一个纯 python 库,应该是跨平台的,但是也存在多监视器问题.

You may wish to look into the pyscreenshot library, its a purely python library and is supposed to be crossplatform, however also has issues with the multi monitor problem.

另一种方法是调用您正在使用的特定操作系统的子进程,这意味着通过命令调用其原生功能进行截图,这里是来自这个 stackoverflow 帖子 概述了我的意思:

Another method is to call a subprocess of the specific os you are using, this means calling its native ability to screenshot via command, here is an example on IOS from this stackoverflow post outlining what i mean:

from subprocess import call
call(["/usr/sbin/screencapture", "screen1.png", "screen2.png"])

作者@Mark Setchell

By @Mark Setchell

查看网站已经在 pyautogui 的路线图上制作处理多个屏幕更简单,希望他们能解决这个问题.

Looking at the website its already on the roadmap of pyautogui to make handling multiple screens simpler so hopefully they will resolve this.

还有一篇很长的帖子这里概述了目前存在的问题pyautogui 的多显示器支持.所以不幸的是,如果你的显示器校准不是完全并排的,因为它偏移了 x 和 y,那么看起来 pygame 和 pyautogui 都不会(轻松)支持多显示器截图,至少没有黑客类型的实现值可能为负数.

There is also a long post here outlining the issue as it currently stands with pyautogui's multi-monitor support. So unfortunately as it stands it looks like both pygame and pyautogui do not (easily) support multi-monitor screenshotting atleast without hackish type implementations if your monitor calibrations are not completely side by side as it offsets x and y values to possibly negative's.

最近还有另一个......一如既往......另一个python库,专门用于python中的多监视器屏幕截图,称为desktopmagic.它可用 此处 但是它没有承诺跨平台,事实上仅声明在 Windows 上截取屏幕截图".所以就您的目的而言,它可能不适合.

Latestly there is yet another...as always..another python library specifically for multi monitor screenshots in python called desktopmagic. Its available here however it makes no promises of being crossplatform and infact states only that "takes screenshots on windows". So for your purpose it may not be suitable.

无论如何希望这对您有所帮助,或者至少为您提供更多选择.希望你的项目成功.

Anyway hope this helps in anyway or atleast gives you more options. Hope your project works out.

这篇关于Python跨平台兼容多屏截图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆