Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Capture mouse movement and export to image [code | app]

To get more in depth information about the usage of WinForm or Webapplications I want to capture mouse-movement and click information. It would be perfect if this could be rendered to an image.

The result would be something like this:

Google: capture display "mouse movement" app to image
The question is how does one start with creating an app like this?

  • How do I receive mousemovements and clicks when its a process from another application?
  • How convert mousemovements to an image?

(Anyone know if there is a opensource of free/cheap app which can do this)

IOGraphica is able to do this, but it is in Java and it is free, but not open source.

like image 988
Ralf de Kleine Avatar asked Mar 03 '11 13:03

Ralf de Kleine


2 Answers

I would try to capture any mouse movement/click of your windows and store it in a collection. When you finished recording - try to draw your image. I would recommend looking for "c# capture mouse" or "mouse hook" in google. Some time ago I did this for getting a keyboard hook. You may have a look at Processing Global Mouse Events.

In terms of code this may help:

Dictionary<Point, MouseEventInfo> dict = new Dictionary<Point, MouseEventInfo>();

/// see given link to find the correct way to get this kind of event
public void mouse_event(....)
{
   /// get mouse coordinates

   /// create point struct

   /// check if point exists in DICT

   /// no - add new MouseEventInfo at Point

   /// yes - access MouseEventInfo object and increase a value according to the event

}

public void onFinished()
{
     /// create new bitmap/image - width/height according to your screen resultion

     /// iterate through all MouseEventInfo objects and draw any information

}

/// stores mouse event info for a point
class MouseEventInfo
{
      Point p;
      int moved=0;
      int clicked=0;
      int doubleClicked=0;
}

I know this is just a piece of pseudoCode - anyway - I hope this may help you! Ah - keep in mind that any kind of hook (keyboard, mouse or anything else) may result in a virus alert of your antiVir.

hth

like image 123
Pilgerstorfer Franz Avatar answered Nov 17 '22 06:11

Pilgerstorfer Franz


If you're looking for something which you could run externally and track mouse movement and clicks, you might find this mouse/keyboard hooking project over at codeproject.com useful:

http://www.codeproject.com/KB/system/globalmousekeyboardlib.aspx

There's a sample application and a hooking lib with full source. It'd be a starting point to use in your efforts.

like image 25
itsmatt Avatar answered Nov 17 '22 06:11

itsmatt