1

I'm building a "WPF Application" which is made to be run in the background (minimised state) and detects KeyStrokes of each and Every key on the keyboard & every Mouse Clicks.

So, my question is how to detect every keyStrokes whether app (Window) is minimised or not.

Simply, if my app is in focus then i use this code to count keystrokes.

Public int count;
protected override void OnKeyDown(System.Windows.Input.KeyEventArgs e)
{
    //base.OnKeyDown(e);
    count++;
    tBlockCount.Text = count.ToString();
}

I just want to do the same even if my app is minimised.

I've searched a lot and come across many suggestions like..

Most of those are indicating towards Registering HotKeys. But I'm unable to match scenario with mine.

Any kind of suggestion are most welcome.

Community
  • 1
  • 1
Keval Langalia
  • 1,762
  • 1
  • 16
  • 29

1 Answers1

2

Although I'm not really condoning the use of a keylogger (This is what you are trying to do). I would recommend taking a look at this q/a, the section near the bottom of this article, and this article for some inspiration. These should help point in the right direction for the coding side.

What you essentially need to do is just set up an event to intercept any keys that come in from the computer, then you can gather the key and do whatever you like with it (in your case, record it)

Edit: In fact, reading the third article, it actually gives a full code snippet on how to implement and use it in WPF, so I recommend just reading that one.

Community
  • 1
  • 1
Dylan Corriveau
  • 2,561
  • 4
  • 29
  • 36
  • Great..!! Sorry for late reply but I was checking the links you gave. the third one works as you said. I've modified that code and integrated exactly as i wanted. I'll post the code here so anyone in future comes here, they'll have exact solution. my fault, i couldn't identify that the thing i want to create is just like "KeyLogger". Thanks a lot..!! – Keval Langalia May 12 '14 at 13:04
  • Not a problem. How has this turned out so far? Has it worked for you? – Dylan Corriveau May 13 '14 at 18:58