For more context basically what i want to do is have my winform app which the form is color whitesmoke and the transparencykey is whitesmoke and i have 2 panels on it open, and its topmost so its overlaying over everything, and if im focused on another app like my browser and i press a key it hides the panels, but if i press the key again it shows it again even if im not focused on the form.
private void Form1_Load(object sender, EventArgs e)
{
this.TopMost = true;
}
private void Form1_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.L)
{
this.Opacity = 100;
this.TransparencyKey = Color.WhiteSmoke;
guna2ShadowPanel1.Visible = true;
guna2ShadowPanel2.Visible = true;
}
}
private void guna2ShadowPanel1_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
{
if (e.KeyCode == Keys.L)
{
guna2ShadowPanel1.Visible = !guna2ShadowPanel1.Visible;
guna2ShadowPanel2.Visible = !guna2ShadowPanel2.Visible;
this.Opacity = 0;
this.TransparencyKey = Color.Black;
}
}
Tried this and it kinda worked, i had to focus on a panel which was annoying, but when i pressed my L key while i clicked the panel once it hid the panel, but the thing im mad about is i had to go back to the form which was invisible from my task bar and press L again.