开发者

How can I get the window at a certain X, Y position with Python and PyGTK/PyGDK?

So, I develop a small screenshot utility called Lookit, and I'm wanting to have the user be able to screenshot an entire window (currently entire screen and dragged rectangle capture are supported).

What I'm wondering is how to get the Window that the us开发者_开发问答er clicks on so that I can find it's geometry and grab that section of the screen.

Any help is appreciated.

Thanks!


Those windows belong to other processes, so you have to go through the windowing system. This is different for each platform, and AFAIK not abstracted by GDK.

On X11 you could use the python bindings to libwnck:

import wnck
screen = wnck.screen_get_default()
for window in reversed(screen.get_windows_stacked()):
    if window.get_geometry() <matches your click coordinates>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜