Here is my code :
System.Windows.Forms.Form form=new System.Windows.Forms.Form();
Button button = new Button();
button.Click += (sender,e)=>
{
form.Hide();
if (Console.ReadKey(true).Key == ConsoleKey.A)
{
form.BringToFront();
form.Activate();
}
};
form.Controls.Add(button);
form.ShowDialog();
And the error:
System.InvalidOperationException: Impossible de lire les touches lorsque l'application ne possède pas de console ou lorsque l'entrée sur la console a été redirigée à partir d'un fichier. Essayez Console.Read.
(Google trad translation : Can not read the keys when the application has no console or where entry on the console has been redirected from a file. Try Console.Read)
à System.Console.ReadKey(Boolean intercept)
à TestHideForm.Class1.<>c__DisplayClass1.<Execute>b__0(Object sender, EventArgs e) dans c:\Users\asabatier\Desktop\Test Hide Form\TestHideForm\TestHideForm\Class1.cs:ligne 32
à System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
à System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
à System.Windows.Forms.Control.WndProc(Message& m)
à System.Windows.Forms.ButtonBase.WndProc(Message& m)
à System.Windows.Forms.Button.WndProc(Message& m)
à System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
Thanks for your help!