1
from xpresser.image import Image
8
# pygtk is using a deprecated method from numpy in get_pixels_array().
9
warnings.filterwarnings("ignore", ".*use PyArray_NewFromDescr.*")
13
pyatspi.Registry.generateMouseEvent(x, y, pyatspi.MOUSE_B1C)
16
pyatspi.Registry.generateMouseEvent(x, y, pyatspi.MOUSE_ABS)
18
def take_screenshot(x=0, y=0, width=None, height=None):
19
window = gtk.gdk.get_default_root_window()
20
if not (width and height):
21
size = window.get_size()
26
pixbuf = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, False, 8, width, height)
27
pixbuf = pixbuf.get_from_drawable(window, window.get_colormap(),
28
x, y, 0, 0, width, height)
29
array = pixbuf.get_pixels_array()
30
return Image("screenshot", array=array,
31
width=array.shape[1], height=array.shape[0])