private void GrabImage_Executed(object sender, ExecutedRoutedEventArgs e) { Process process = Process.GetCurrentProcess(); ShowWindow(process.MainWindowHandle, (int)ShowState.SW_SHOWMINIMIZED); var windowStyle = WindowUtils.GetFormState(process.MainWindowHandle); if (windowStyle == FormWindowState.Minimized) { Thread.Sleep(800); ScreenshotDialog dialog = new ScreenshotDialog(); dialog.TransfEvent += Dialog_TransfEvent; if (dialog.ShowDialog() == DialogResult.OK) { ShowWindow(process.MainWindowHandle, (int)ShowState.SW_RESTORE); } } }