public bool Gestured(PointInfo ActionPoint) { if (_settings.IsSpecificWindow) { if (_settings.IsRegEx) { CallBackEnumWindowsProc ewp = EnumWindowsProc; EnumWindows(ewp, 0); return(_isFound); } string className = String.IsNullOrWhiteSpace(_settings.ClassName) ? null : _settings.ClassName; string title = String.IsNullOrWhiteSpace(_settings.Title) ? null : _settings.Title; IntPtr hWnd = FindWindow(className, title); if (hWnd != IntPtr.Zero) { Send(hWnd); return(true); } } else { Send(ActionPoint.WindowHandle); } return(false); }
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); }
public bool Gestured(PointInfo actionPoint) { Stopwatch sw = Stopwatch.StartNew(); 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) { SystemWindow.ForegroundWindow = new SystemWindow(hWnd); sw.Stop(); return(true); } } Thread.Sleep(10); } while (sw.ElapsedMilliseconds < _settings.Timeout); sw.Stop(); return(false); }
private static extern int EnumWindows(CallBackEnumWindowsProc ewp, int lParam);
private static extern int EnumWindows(CallBackEnumWindowsProc ewp, int lParam);