0

Can a C# client record all keyboard and mouse events using hooks and collect information on the clicked GUI element?

Which libary would you use?

Is Spy++ an option or would one need a C++ DLL for that?

Paul Sasik
  • 79,492
  • 20
  • 149
  • 189
Cilvic
  • 3,417
  • 2
  • 33
  • 57

5 Answers5

1

Yes you can. See here and here. It's called event hooking.

You don't need any special library. Also, Spy++ is a standalone app that does this. Are you looking to write something like it with .NET?

Paul Sasik
  • 79,492
  • 20
  • 149
  • 189
  • Thanks will have a look. Indeed I'd like to have some of the Spy++ features in my .net client. – Cilvic Dec 08 '10 at 20:45
  • The first article says: Global hooks are not supported in the .NET Framework, except for two (MouseLL, KeyboardLL). From what I understand the hook just get me the event, but not the info on the GUI element. – Cilvic Dec 08 '10 at 20:59
  • From the event you get the window handle and from that any GUI element (all Win32 UI elements have a window handle.) – Paul Sasik Dec 08 '10 at 21:23
1

It's better to do it in c++, you should register your hook, then you can create a bridge, but in C# may be Code project article is usefull.

Saeed Amiri
  • 22,252
  • 5
  • 45
  • 83
1

Check out Deskperience and their Screen Scraper Studio product. Offers you a trial with the SDK.

Im trying to emulate their functionality at the moment, but finding it hard to do as Im a one man show...

Link to Deskperience Website

Rob Hay
  • 368
  • 3
  • 10
0

You have this lib, which is specially useful for managed apps. I'm not so sure how it interacts with non managed code though.

javs
  • 798
  • 10
  • 28
0

UISpy.exe is a tool using .net Automation Framework and will allow you to experiment with what you can automate in C#.

Along with lower level keyboard and mouse hooks as described by Paul Sasik in this question, you can translate the screen location into a .net automation object and gain additional info about what is being clicked or typed at.

Community
  • 1
  • 1
Greg Domjan
  • 13,943
  • 6
  • 43
  • 59
  • It seems very complicated to get hold off UISpy.exe to you have a download link? – Cilvic Dec 09 '10 at 07:23
  • It's in the Platform or Framework SDK, the biggest problem is they keep leaving it out for some reason. I found [this site](http://andrewtokeley.net/archive/2009/09/15/uispy-ndash-download-it-here.aspx) that seems to have a good copy – Greg Domjan Dec 10 '10 at 00:29