在OSX上使用python截取第二台显示器的屏幕截图

Bru*_*taz 7 python macos screenshot

我正在尝试用Python制作环境光系统.我已经获得了pyscreenshot以正确保存截图,但我无法弄清楚如何将其截屏我的第二台显示器(如果这是可能的话).

有没有办法使用pyscreenshot(或其他东西)在Python中截取我的第二台显示器的屏幕截图?我正在使用OSX优胜美地,如果这有任何区别.

Mar*_*ell 6

使用内置screencapture命令并传递2个文件名.我相信它存在于/usr/sbin/screencapture所以命令将如下所示:

/usr/sbin/screencapture screen1.png screen2.png
Run Code Online (Sandbox Code Playgroud)

我假设您知道如何使用该subprocess模块对它进行外壳处理

from subprocess import call
call(["/usr/sbin/screencapture", "screen1.png", "screen2.png"])
Run Code Online (Sandbox Code Playgroud)