捕获按钮,复选框从其他应用程序单击 [英] Capturing button, checkbox clicks from another application

查看:84
本文介绍了捕获按钮,复选框从其他应用程序单击的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

曾多次问过这个问题,但仍然没有得到答案。至少在几个星期之后我的问题变得更加......可以理解我猜...



到目前为止,我正在尝试创建一个应用程序来做第二件事:我运行aplication。当它正在工作时,当我点击另一个应用程序中的按钮或复选框/ radiobutton时,我得到了它的名字。例如:粗体,文件,查看(Microsoft Word)。我不需要更多。



我正在使用此应用程序创建统计信息,用户在某个应用程序中单击的内容(例如,Microsoft Word),有多快(等一些研究)。



老实说,如果只有它可以获得一个名字(不包括无知的情况),它对我来说就足够了仅适用于Microsoft Word / Point等。



现在我设法找到的是:鼠标钩子,它允许我在外面创建XY应用程序(好吧,有用)对我来说)。我发现这与Spy ++类似。从理论上讲,它可以通过获取句柄或事件来完成。



但是......可以用C#做​​吗?什么可以用来创建这种应用程序? (如果在C#中不可能的话)?



PS抱歉我的英文不好。

解决方案

Bad理念。一般情况下,这是不可能的。这些过程被设计成隔离的,以最大限度地减少来自其他进程的干扰,消除内存中的冲突(每个进程在一个单独的内存空间中执行,这是基于内存的硬件隔离)。



在某些情况下,这是可能的,但你事先不知道。例如,如果应用程序基于WPF,或者更一般地说是DirectX,则在按钮级别没有消息。从Windows消息传递系统的角度来看,这些按钮根本不存在(然后是轻量级,而不是窗口化)。在特殊情况下,当您的远程按钮是窗口控件时,您可以使用全局(!)Windows Hooks捕获Windows消息。对于全局钩子,使用.NET应用程序是不够的,您还需要编写本机(非托管)DLL,在那里编写钩子句柄并安装钩子。请看我最近的回答:

是否有办法在客户端系统上运行程序以查看在主机远程桌面窗口内发生的事件? [ ^ ]。



另请参阅我对该主题的其他答案:

http://msdn.microsoft.com/en-us/magazine/cc188966.aspx [ ^ ],

系统空闲时间让用户空闲 [ ^ ],

键盘挂钩如何工作以及如何实施 [ ^ ],

如何在其他应用程序中设置窗口挂钩? [ ^ ],

创建全局快捷方式。 [ ^ ]。



您需要为 WH_安装一个钩子程序GETMESSAGE ,再次,在本机代码中,而不是.NET。请参阅: http://msdn.microsoft.com /en-us/library/windows/desktop/ms644990%28v=vs.85%29.aspx [ ^ ]。



< DD> -SA

Tried to ask this several times, but still didn't get an answer. At least after several weeks my question are became more... understandable I guess...

So far I am trying to create an aplication which will do second things: I run aplication. While it is working, when I am clicking on button or checkbox/radiobutton in another aplication, i am getting its name. For example: "Bold", "File", "View" (Microsoft Word). I don't need more than that.

I am doing this application to create statistic, what users are clicking inside some application (again, Microsoft Word for example), how fast and ect (somekind of research).

Honestly, it will be enough for me if it works only if it can get a name (exclude wondowless situations) and only for Microsoft Word/Point and etc.

Right now all I managed to found is: Mouse hook, which allow me to get XY outside created application (well, usefull to me to). I figured out that this is something similar to Spy++ i guess. Theoretically it can be done by getting handle or events.

But... is it possible to do in C#? What can be used to create this kind of application? (If its not possible in C#)?

P.S Sorry for my bad english.

解决方案

Bad idea. In general case, this is impossible. The processes are designed to be isolated, to minimize possible intervention from other processes, eliminate clashes in memory (each process is executed in a separate memory space, which is based on hardware isolation of memory).

In some cases, it is possible, but you never know in advance. For example, if the application is based on WPF, or, more generally, DirectX, there is no message pumping at the level of buttons. From the standpoint of Windows messaging system, those buttons simply don't exist (then are "light-weight", not windowed). In special cases, when your "remote" buttons are windowed control, you can capture windows message using global(!) Windows Hooks. For global hooks, using .NET application won't be enough, you will also need to write a native (unmanaged) DLL, to write your hook handles there and install the hooks. Please see my recent answer:
Is there a way for a Program ran on a Client system to See events that happen inside the Host Remote Desktop Window?[^].

See also my other answers on the topic:
http://msdn.microsoft.com/en-us/magazine/cc188966.aspx[^],
System Idle Time for user being idle[^],
How the Keyboard Hook works and how it is being implemented[^],
How to set a window hook in other application?[^],
Creating global shortcuts.[^].

You would need to install a hook procedure for WH_GETMESSAGE, again, in native code, not .NET. Please see: http://msdn.microsoft.com/en-us/library/windows/desktop/ms644990%28v=vs.85%29.aspx[^].

—SA


这篇关于捕获按钮,复选框从其他应用程序单击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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