Image

Grabbing image from foreign window via PyQt / Linux

Greetings!

Please pardon my poor english, if readable at all. It isn't native language.

There is my PyQt application and there is window of some Other Program running at the same X11 display.

I found a good and easy receipt how to grab whole screen using QPixmap.grabWindow.

But I need to grab not the whole screen. Only image from this Other Program's window. Just like KSnapShot does it when I choose "window under cursor" and "not include window decorations" options.

QPixmap.grabWindow receives winId as it first parameter, but I don't know how can I get winId if I know PID of that Other Program or title of its window.

I've tried to google it but failed. =\
I've also tried to look into KSnapShot source code to understand how they had done it; but it seems like my Cpp or Qt level is not enough for understanding that.


Is there a more or less easy way to get winId of that foreign window or maybe some another overall way to grab image from foreign program window via Python?

Thanks!

PS: Sorry, if this question is stupid. I'm not very cool at Python and new to Qt.