Untitled.png

hello
i am currently working on a python program that remote controlls multiple computers at once, as if they were multiple screens of one computer.

one of the features of this program, is that the server controlling all computers, builds a map from screens, and including its own - server screen.
But when the server controlls its own screen, a recurtion effect starts, because it takes screenshots of the screenshots it show on the screen, and so on..

Here's the rough code of the screen capture i use (With PIL)

def capture_screen(self):
    screen_contents = ImageGrab.grab()
    size = win_width, win_height
    screen_contents = screen_contents.resize(size, Image.ANTIALIAS)
    screen_image = ImageTk.PhotoImage(screen_contents)
    self.screen_displayer.config(image = screen_image)
    self.screen_displayer.image = screen_image
    self.screen_displayer.grid(row = 0, column = 0)
    #update display
    self.master.after(200, self.capture_screen)

Is there a way to make my screen capture ignore the active frontal window, and give a shot of everything except for it?

p.s- I found a discussion about this topic, but couldn't find a solid solution. only theories.
the link - https://www.daniweb.com/programming/software-development/threads/169406/screen-capture-ignoring-active-window

If anyone could help it'd be greatly appreciated.
Thanks in advance,
Guy

guy0282@gmail.com