-3

I'm writing a c# console application and I want it to monitor all keyboard input, even when other programs have focus, so that if a person hits a specific key combination (from anywhere), my code will be activated.

Currently when I run my program and then select another program, my program does not do anything when I enter the key combination.

A thread might be a good idea.

Sorry for my grammar and English. I try to explain it good.

Rufus L
  • 36,127
  • 5
  • 30
  • 43

1 Answers1

2

Console application is not suitable for that. you should be looking for Keyboard Hook.

Have a look at this question.

Ashkan Mobayen Khiabani
  • 33,575
  • 33
  • 102
  • 171
  • 1
    If your answer is a link to another, similar question, wouldn't it be more appropriate to mark this as a duplicate? – Rufus L Aug 24 '17 at 04:27
  • 1
    @RufusL I usually do that, but in this question the user hasn't asked how should he use hooks, and actually his question shows that he does not know about hooks. So I wanted to suggest him to search about hooks. I thought a question about hooks would be of more help. but it is not the same question to mark it as duplicate – Ashkan Mobayen Khiabani Aug 24 '17 at 04:31