1

I wanted to ask.Im doing a program that when its minimized or some other window are opened to read my keys and if "specific" is pressed to do something. I used InputSimulator but its working only when a program is in normal window state.if program are minimized. didnt responde?What should i use to make it working in background ?

  • You would probably need to do this low level, with calls into the Windows API. Key presses aren't passed into your application's message queue if the kernel thinks it shouldn't (like it doesn't have any focus). – Zer0 Feb 21 '19 at 14:26
  • Minimized programs do lose focus, other approaches would require windows API (@Zer0's comment) or creating a driver (not recommended in c#, kinda lack of information imho) – Cleptus Feb 21 '19 at 14:44
  • Does this answer your question? [How to intercept all the keyboard events and prevent losing focus in a WinForms application?](https://stackoverflow.com/questions/17579658/how-to-intercept-all-the-keyboard-events-and-prevent-losing-focus-in-a-winforms) – Addio Sep 28 '22 at 02:17

1 Answers1

2

You should use RegisterHotKey API functions to regist hotkeys for your processes, also here is an example for it.

koviroli
  • 1,422
  • 1
  • 15
  • 27