public bool Gestured(PointInfo actionPoint) { var tick = Environment.TickCount; do { if (_settings.IsRegEx) { CallBackEnumWindowsProc ewp = EnumWindowsProc; EnumWindows(ewp, 0); if (_isFound) { return(true); } } else { string className = String.IsNullOrWhiteSpace(_settings.ClassName) ? null : _settings.ClassName; string caption = String.IsNullOrWhiteSpace(_settings.Caption) ? null : _settings.Caption; IntPtr hWnd = FindWindow(className, caption); if (hWnd != IntPtr.Zero) { var window = new SystemWindow(hWnd); if (window.WindowState == System.Windows.Forms.FormWindowState.Minimized) { window.RestoreWindow(); } SystemWindow.ForegroundWindow = window; return(true); } } Thread.Sleep(10); } while (_settings.Timeout > 0 && Environment.TickCount - tick < _settings.Timeout); return(false); }
private bool ShowControlPanel() { Process current = Process.GetCurrentProcess(); var controlPanelProcesses = Process.GetProcessesByName(current.ProcessName); if (controlPanelProcesses.Length > 1) { foreach (Process process in controlPanelProcesses) { if (process.Id != current.Id) { var window = new SystemWindow(process.MainWindowHandle); if (window.WindowState == System.Windows.Forms.FormWindowState.Minimized) { window.RestoreWindow(); } SystemWindow.ForegroundWindow = window; break; } } return(true); } return(false); }
private bool EnumWindowsProc(IntPtr hWnd, int lParam) { if (IsWindowVisible(hWnd)) { try { var window = new SystemWindow(hWnd); if ( Regex.IsMatch(window.Title, _settings.Caption, RegexOptions.Singleline | RegexOptions.IgnoreCase) && Regex.IsMatch(window.ClassName, _settings.ClassName, RegexOptions.Singleline | RegexOptions.IgnoreCase)) { _isFound = true; if (window.WindowState == System.Windows.Forms.FormWindowState.Minimized) { window.RestoreWindow(); } SystemWindow.ForegroundWindow = window; return(false); } } catch { _isFound = true; return(false); } } _isFound = false; return(true); }