简体   繁体   English

如何在python 2.7 for mac中截取背景应用程序的截图

[英]How to take screenshot of background app in python 2.7 for mac

I have been trying to make a program that notifies me when a number changes on an app. 我一直试图制作一个程序,当应用程序上的数字发生变化时通知我。 I have been using ImageGrab and then pytesseract which works but I can only figure out how to take the screenshot when I can visually see the number. 我一直在使用ImageGrab然后pytesseract工作,但我只能弄清楚如何在视觉上看到数字时截取屏幕截图。 It would be very nice if there was a way to take an image of the app if it was minimized (not visible on the screen) so I could work on other things as it ran. 如果有一种方法来获取应用程序的图像(如果它被最小化(在屏幕上看不到))那将是非常好的,所以我可以在运行时处理其他事情。 I also need the picture of a certain part of that app I need to do a bounding box within the app of where the picture is taken. 我还需要该应用程序的某个部分的图片,我需要在应用程序中拍摄照片的边界框。

This is what I am currently using which takes a certain part of the whole screen: 这是我目前正在使用的,它占据了整个屏幕的某个部分:

img = ImageGrab.grab(bbox=(1400,875,1445,905)) img = ImageGrab.grab(bbox =(1400,875,1445,905))

I think there might be a way to do it with Quartz but I could not find out how to do a region of a background app. 我认为可能有一种方法可以使用Quartz,但我无法找到如何做一个后台应用程序的区域。

You can screenshot what is on your screen. 您可以截图屏幕上的内容。 If the app is minimized, that number you're looking for is not on the screen. 如果应用程序最小化,您正在寻找的那个号码不在屏幕上。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM