是否可以在 Linux 中以编程方式单击另一个应用程序的按钮?
是否可以将事件发送到特定的小部件(例如按钮) 在Linux(X窗口系统)中,
我正在寻找与Linux以下代码等效的代码(使用Xlib)
#include <windows.h>
int main()
{
HWND WindowHandle;
HWND ButtonHandle;
WindowHandle = FindWindow(NULL, "File Download");
ButtonHandle = FindWindowEx(WindowHandle, 0, "Button", "&Open");
SendMessage (ButtonHandle, BM_CLICK, 0 , 0);
return 0;
}
我猜想FindWindow
可以通过XFetchName来模拟,但我不知道如何 按名称查找特定小部件的 ID (FindWindowEx) 在我只知道小部件“名称”的情况下(即按钮的情况下的标题)。
我可以这样做吗?
Is it possible to send an event to a particular widget (say a button)
in Linux (X window system)
I am looking for an equivalent to the following code for Linux (using Xlib)
#include <windows.h>
int main()
{
HWND WindowHandle;
HWND ButtonHandle;
WindowHandle = FindWindow(NULL, "File Download");
ButtonHandle = FindWindowEx(WindowHandle, 0, "Button", "&Open");
SendMessage (ButtonHandle, BM_CLICK, 0 , 0);
return 0;
}
I guess that FindWindow
can be simulated by XFetchName, but I have no idea how
to find a particular widget's ID by name (FindWindowEx)
in the case where I only know the widget "name" (i.e. caption in the case of a button).
Can I do that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
也许,使用 XTest 扩展:
http://www.x。 org/releases/X11R7.5/doc/Xext/xtestlib.pdf
但是,没有可移植的方法来确定屏幕上什么是小部件,什么不是小部件,因为某些 GUI 工具包将所有内容渲染为单独的 X 对象, 尽管其他人先进行自己的合成。
Maybe, using the XTest extension:
http://www.x.org/releases/X11R7.5/doc/Xext/xtestlib.pdf
However, there is no portable way to determine what is and isn't a widget on the screen, as some GUI toolkits render everything as separate X objects, while others do their own compositing first.