Windows GUI - 找出在屏幕上点击了什么 [英] Windows GUI - Find out what has been clicked on the screen
问题描述
我在 Windows 7 上使用 Eclipse,JNI 和 C.
I'm using Eclipse on Windows 7, JNI with C.
我找不到检测屏幕上点击的内容的方法,例如:Microsoft Word 上的保存文件",或浏览器上的后退导航按钮;我不知道在哪里可以找到好的教程,或者找到它的方法.
I can't find a way to detect what has been clicked on the screen, eg: "Save File" on Microsoft Word, or the back navigation button on my browser; I don't know where to find a good tutorial, or a way to find it out.
有人能告诉我我应该学习什么来实现这一目标吗?
Would someone please tell me what should I study to achieve this?
:直到今天,我通过以下方式获得了活动窗口的标题:
: until today, I achieved to get the title of the active window by:
// In which window it has been typed/clicked something?
void whichWindow(void) {
HWND foreground = GetForegroundWindow();
char window_title[256];
if(foreground) {
GetWindowText(foreground, window_title, 256);
printf("active window title: %s\n", window_title);
}
}
我会在何时能够检索到单击的窗口元素时通知您.
I'll let you know when I'll be able to retrieve the window's elements clicked.
推荐答案
网上有几个程序可以做到这一点.IIRC winspy 就是其中之一.它通过设置一个全局鼠标钩子来实现这一点,该鼠标钩子返回单击窗口的程序名.如何在 JNI 中抽象它?不知道,但这是您要求的链接:
There are several programs on the web which do this. IIRC winspy is one of them. It achieves this via setting a global mousehook which returns the programname of the clicked window. How to absract this in JNI? Do not know, but this is the link, you asked for:
http://www.codeproject.com/Articles/1037/Hooks-和-DLL
这篇关于Windows GUI - 找出在屏幕上点击了什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!