0

I was wondering how do I use a hotkey on keyboard to hide and show the entire form in C# ?

I already tried something, but the form must be in focus.

Is there any way to do it without the focus, like if i was in other application?

Thanks.

`private void Form1_KeyDown(object sender, KeyEventArgs e)
    {
        if (e.KeyCode == Keys.Q)
        {
            WindowState = FormWindowState.Minimized;
        }
    }

    private void Form1_KeyUp(object sender, KeyEventArgs e)
    {
        if (e.KeyCode == Keys.Q)
        {
            WindowState = FormWindowState.Normal;
        }
    }`

I tried this but this just doesn't work at all.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Ondřej
  • 11
  • 1
  • 1
    Look for the [RegisterHotKey](https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-registerhotkey) function -- BTW, do not register a simple Key (as `A`, `B`, `C` etc.), but a combination of key modifiers and other keys (e.g., `CTRL + SHIFT + Q`) – Jimi Feb 04 '23 at 19:10

0 Answers0