Click here to Skip to main content
15,887,294 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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.
Posted
Updated 17-Apr-14 14:11pm
Comments
Sergey Alexandrovich Kryukov 17-Apr-14 20:20pm    
Why suffering so much?
—SA

1 solution

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
 
Share this answer
 
Comments
Member 10503105 18-Apr-14 6:15am    
Was afraid of it... well, as an atlernative I thinked about second thing: get a coordinates by using Mousehook. Then get a little picture around clicked place, but again, do i need to make a screenshot, then cut needed piece from it?
Sergey Alexandrovich Kryukov 18-Apr-14 10:34am    
Not sure; in .NET the method takes a rectangle of a screen shot.
Why suffering from all that difficulties? Any good purpose?
—SA
Member 10503105 18-Apr-14 12:40pm    
Well, i described already that i need to get a statistic what people are clickin in Word or Point. So if it inposible to get clicked button or other thing names, I need to get something atleast.
Sergey Alexandrovich Kryukov 18-Apr-14 13:28pm    
What a pointless business, I would say. Okay, I answered in detail. You can use the Windows Hook. I basically explained how.
Any problems with that? Are you going to accept the answer formally (green "Accept" button)?
—SA
Member 10503105 18-Apr-14 20:08pm    
Hm..so far i get that i cant use global hooks, but, something callet WindowFromPoint, GetCapture, but honestly, didnt get how to use them. As by... answer, well, sure. Guess I again got a problem with explanation but at least now the sad reality punched me in my face.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900