0

I am trying to use the keyDown method (Ctrl + R) to record the mouse position on the screen. It works perfect when the Form is in front but when I click outside the form, the form turns gray, go to the back and stop the keyDown detection. A label in the form keeps showing the mouse position even when the form is in the back but the keyDown doesn't work. Obviously I know it is the normal action of windows to prioritize the software which is in front and in use but is there a way to make the keyDown method works even when the form is not in front or when the form is minimized. Thanks in advance and I am welcome to any comment, idea or suggestion.

Update: Thanks to the replies I got the answer. I got a library for Global Hotkeys and LowLevelHooks from here: http://www.dreamincode.net/forums/topic/180436-global-hotkeys/

Pablo Gonzalez
  • 673
  • 2
  • 10
  • 24
  • 2
    I think [THIS](http://stackoverflow.com/questions/28785375/c-sharp-wpf-catch-keydown-even-when-minimized) can help you. I used it a while ago for WPF application but it should be identical for WinForms. – MaLiN2223 Feb 23 '17 at 02:01
  • Thank you for your reply. I will check – Pablo Gonzalez Feb 23 '17 at 03:34

1 Answers1

2

what you are looking for is global keyboard hooks which is used to detect keys outside winform you can check this link for code example Keyboard Hook in C#

Usman
  • 4,615
  • 2
  • 17
  • 33