def __init__(self, x1=None, y1=None, x2=None, y2=None): self.x1 = 0 self.y1 = 0 xdo = Xdo() size = xdo.get_window_size(xdo.get_active_window()) self.x2 = size.width self.y2 = size.height if x1: self.x1 = x1 if y1: self.y1 = y1 if x2: self.x2 = x2 if y2: self.y2 = y2
def get_areas(area_map): """Возвращает координаты квадрата для заданой сетки""" if len(area_map) == 0: return 0, 0, 0, 0 xdo = Xdo() size = xdo.get_window_size(xdo.get_active_window()) locations = xdo.get_window_location(xdo.get_active_window()) wnd_w = int(size.width / len(area_map[0])) wnd_h = int(size.height / len(area_map)) result = [] for row_n in range(len(area_map)): for cell_n in range(len(area_map[row_n])): if area_map[row_n][cell_n] == 1: result.append( (wnd_w * cell_n + locations.x, wnd_h * row_n + locations.y, wnd_w * cell_n + wnd_w + locations.x, wnd_h * row_n + wnd_h + locations.y) ) return result
if primary_monitor is None: print("error: primary monitor not found !") print(list_monitors(monitors_list)) sys.exit(3) monitor = monitors_list[primary_monitor] # building ffmpeg / gstreamer streaming command capture_flags = "" if monitor: cmd = CMD_CAPTURE_SCREEN size_width = monitor['width'] size_height = monitor['height'] if args.hide_cursor: capture_flags = " -draw_mouse 0" source = "%s+%d,%d" % (display_num, monitor['x'], monitor['y']) else: cmd = CMD_CAPTURE_WINDOW size = xdo.get_window_size(window) size_width = size.width size_height = size.height if args.hide_cursor: capture_flags = " show-pointer=0" source = window cmd = cmd.format(framerate=FRAMERATE, size_width=size_width, size_height=size_height, loglevel=loglevel, ip=args.ip, port=args.port, source=source, capture_flags=capture_flags) # execute ffmpeg / gstreamer command print("[+] running '%s'" % cmd) subprocess.call(cmd, shell=True)