Get the pressed key with minimized application or without focus c#

Asked

Viewed 444 times

3

I would like to press the Printscreen on the keyboard, the C# application that is minimized in the Tray system, be maximized and display the image of the print.

1 answer

4

I don’t think there’s an easy way to do this, but this (using windows message to implement Global System Hook in C #) can help. I added the code below

 _GlobalHooks.Keyboard.KeyboardEvent += (w, l) => 
{
      this.LblKey.Text = "KEY: " + w.ToInt32().ToString("X8") + " " + l.ToInt32().ToString("X8");
};
_GlobalHooks.Keyboard.Start();

for the Form1 builder of Globalhooktest and was able to monitor all keyboard events.

Here Git has a complete project using Global System Hook in C# https://github.com/gmamaladze/globalmousekeyhook

Browser other questions tagged

You are not signed in. Login or sign up in order to post.