Hide form through C#keys

Asked

Viewed 159 times

2

I’m making a menu in c# and the same only opens when the game is open or running, IE, if the game is running show the menu, so everything well it performs, but I wanted to hide the menu for example by pressing F1 on the keyboard without using minimize button of the form window, then show again when pressing the button until pq to using bordernone has the minimize and do not close buttons. I have tried some tutorials on the net more as I am beginner I made the biggest mess here =/. Could anyone help me? since already grateful.

  • If this game goes into full screen, it will be a little difficult to circumvent, even "team Speak" uses Overwolf to achieve this feat :/

  • Thanks vicnius but I just found this tutorial last minute. 1° follow this tutorial by creating the Keyboardhook class: https://wphone7.wordpress.com/2008/08/23/easy-way-global-keyboard-hooking-in-net-application/ 2° then: https://wphone7.wordpress.com/2008/08/29/hiding-windows-form-in-c-using-global-keyboard-shortcut/

1 answer

2


On your screen, you can use the event KeyDown to capture the pressing of a key. In case you are using Windows Forms, do not forget to set the property KeyPreview form for True.

private void MeuFormulario_KeyDown(object sender, KeyEventArgs e)
{
    if (e.Control && e.KeyCode == Keys.F1)
    {
        this.WindowState = FormWindowState.Minimized;
    }
}

Just don’t forget to link the event with the method.

  • Thanks Vinicius for responding, but I ended up finding the 48 a tutorial , have to use hook heyboard.

  • 1

    Put the solution there for us, as an answer, so you can end up helping more people who have the same question.

Browser other questions tagged

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