private void OnStateChanged(object sender, EventArgs e) { if (this.WindowState == WindowState.Minimized) { this.Topmost = false; this.ShowInTaskbar = false; resetPlayer(); // notifyIcon.Visible = true; } else { // notifyIcon.Visible = true; this.ShowInTaskbar = true; this.Topmost = true; this.Activate(); search.Focusable = true; FocusManager.SetFocusedElement(mainw, search); Keyboard.Focus(search); KeyPress.press(); } }