Search code examples
c#xmlcounterkeystroke

Create a simple Keystroke counter for statistics, seperate Key's, To XML


I want to create a small process in C# that counts my keystrokes and saves them to an xml file. One entry for every hour. I want to create some statistics about the count of my typing with this. I imagine the xml file:

Structure:

<keystrokes>
    <entry time = [date and time ]>
        <key id = [Key-id]>[Amount of keystrokes]</key>
        <key id = [Key-id]>[Amount of keystrokes]</key>
        .
        .

    </entry>
   .
   .
</keystrokes>

Example:

<keystrokes>
    <entry time = "25.08.2015_14:00_15:00">//counted keystrokes between 14:00 and 15:00
        <key id = "A">34</key>
        <key id = "B">45</key>
        .
        .
    </entry>
   .
   .
</keystrokes>

Update frequently the current entry. For example: write every 10 sec the counted keystrokes to the xml to prevent data loss. A perfect solution would be an integrated mouse click counter.

I hope you can explain how to get access to the keystrokes and how to work with them and C#. Thank you very much.


Solution

  • It's basically a keylogger with analytics.

    To build the keylogger itself, see this SO answer. To gather statistics, I'd recommend using an SQLite database: it's very lightweight, easy to use and performant.