[英]Qt/C++ get Xid of all application windows
I'm using gstreamer with Qt/C++ and I'd like to use "ximagsrc xid=[MyXid]", replacing [MyXid] by the Xid of every windows on my computer. 我正在将gstreamer与Qt / C ++一起使用,我想使用“ ximagsrc xid = [MyXid]”,用计算机上每个窗口的Xid替换[MyXid]。 I found the following command line :
我发现以下命令行:
wmctrl -l
0x02a00002 0 Fry XdndCollectionWindowImp
0x02a00005 0 Fry unity-launcher
0x02a00008 0 Fry unity-panel
0x02a0000b 0 Fry unity-dash
0x02a0000c 0 Fry Hud
0x02c0000a 0 Fry Desktop
...
to get the IDs. 获取ID。 (I'am able then to use "ximagsrc xid=0x02a00002" for example)
(例如,我可以使用“ ximagsrc xid = 0x02a00002”)
But I'm programming in Qt/C++ and 但是我正在用Qt / C ++和
I'd like to get these values automatically. 我想自动获取这些值。 I could launch this command line through C++ but if "wmctrl" isn't installed on the computer, my program wouldn't work.
我可以通过C ++启动此命令行,但是如果计算机上未安装“ wmctrl”,则我的程序将无法运行。 (it also seems to be a bad way for me, isn't it ?)
(对我来说这似乎也是一种不好的方法,不是吗?)
Is there any way to do this with C++ or Qt ? 有没有办法用C ++或Qt做到这一点?
Thank you, 谢谢,
Have a nice day ! 祝你今天愉快 !
Instead of using wmctrl
, you could also use xwininfo
, which may be more readily available. 除了使用
wmctrl
,您还可以使用xwininfo
,它可能更容易获得。
If you want to implement this functionality in your program, you can use xlib or xcb to implement a client that retrieves this information from the X server. 如果要在程序中实现此功能,则可以使用xlib或xcb来实现从X服务器检索此信息的客户端。 Check the source code of
wmctrl
or xwininfo
to see how they do it. 检查
wmctrl
或xwininfo
的源代码以了解它们的工作方式。
尝试使用xwininfo : xwininfo -root -children
Thanks for you answers. 感谢您的回答。
I finally took the source code of wmctrl and changed it to get what I needed I guess it can work with windows. 最后,我获取了wmctrl的源代码并对其进行了更改,以获取所需的东西,我猜它可以在Windows上运行。 Unfortunately, it doesn't work for Mac but anyway gstreamer for Mac recording screen is still a bad plugin unable to do this.
不幸的是,它不适用于Mac,但无论如何,适用于Mac录制屏幕的gstreamer仍然是一个糟糕的插件,无法执行此操作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.