如何在java中获取所有windows元素的class / caption / handle [英] How to get class/caption/handle of all windows elements in java

查看:177
本文介绍了如何在java中获取所有windows元素的class / caption / handle的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在java中创建一个类似于spy ++的应用程序,其中我遇到问题是获取我正在抓取鼠标的每个元素的类/句柄/标题。



如果我们在任务栏上移动鼠标,间谍工具会显示以下信息:句柄:000100AA标题:运行应用程序类:MSTaskListWClass

如果我们将鼠标放在Windows计算器的一个按钮上(比方说1)间谍工具将显示标题:1类:按钮

我已经获得前景窗口,代码如下:



I am trying to create an app similar to spy++ in java, in which I getting problem to fetch class/handle/caption of every element which I am taking mouse over.

If we move mouse on task bar, the spy tool shows the info as : Handle : 000100AA Caption : Running applications Class : MSTaskListWClass
If we take mouse on one of the button of windows calculator(lets say "1") spy tool will show caption : 1 class:button
I m already getting foreground window with following code:

GetWindowTextW(GetForegroundWindow(), buffer, MAX_TITLE_LENGTH);



和进程名称:




and process name :

Pointer process = OpenProcess(PROCESS_QUERY_INFORMATION
                | PROCESS_VM_READ, false, pointer.getValue());
        GetModuleBaseNameW(process, null, buffer1, MAX_TITLE_LENGTH);



但是我仍然无法获得按钮/文本框的标题和类。请帮忙做同样的事。


But i am still not able to get captions and classes for buttons/textboxes. Please help to do the same.

推荐答案

你需要枚举所有窗口,对于每个窗口,你需要枚举所有的子窗口,并且每个窗口都是子窗口,你需要枚举它的所有子窗口等。我不知道你将如何在Java中这样做,但在C ++中你应该看看 http://msdn.microsoft.com/en-us/library/windows/desktop/ms633497(v = vs.85)。 aspx [ ^ ]及其相关功能。
You will need to enumerate all the windows, and for each window you will need to enumerate all the child windows, and for each child window you will need to enumerate all its child windows, etc. I don't know how you would do this in Java, but in C++ you should look at http://msdn.microsoft.com/en-us/library/windows/desktop/ms633497(v=vs.85).aspx[^], and its associated functions.


这篇关于如何在java中获取所有windows元素的class / caption / handle的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆