/// <summary> /// Gets a list of all visible top-level windows. /// </summary> public IList <Window> GetVisibleWindows() { mWindows = new List <Window>(); User32.EnumWindowsProc evalWindowCallback = EvalWindowCallback; User32.EnumWindows(evalWindowCallback, 0); return(mWindows); }
public static IEnumerable <IntPtr> EnumChildWindows(IntPtr parentHandle) { var list = new List <IntPtr>(); User32.EnumWindowsProc callback = delegate(IntPtr windowHandle, IntPtr lParam) { list.Add(windowHandle); return(true); }; User32.EnumChildWindows(parentHandle, callback, IntPtr.Zero); return(list.ToArray()); }
public static ApplicationWindow FindWindowByCaption(string caption) { ApplicationWindow window = null; var ewp = new User32.EnumWindowsProc((hwnd, lparam) => { var w = ApplicationWindows.GetApplicationWindow(hwnd, lparam); if (w != null && w.Title.Equals(caption, StringComparison.InvariantCulture)) { window = w; } return(window == null); //continue as long as window == null; }); User32.EnumWindows(ewp, 0); return(window); }
private static IEnumerable <ApplicationWindow> FindAltTabableWindows() { var windows = new List <ApplicationWindow>(); var ewp = new User32.EnumWindowsProc((hwnd, lparam) => { ApplicationWindow window = null; var shouldContinue = ApplicationWindows.Filter(hwnd, lparam, out window); if (window != null) { windows.Add(window); } return(shouldContinue); }); User32.EnumWindows(ewp, 0); return(windows.DistinctBy(w => w.hWnd)); }
public static IEnumerable <IntPtr> FindWindows(User32.EnumWindowsProc filter) { IntPtr found = IntPtr.Zero; List <IntPtr> windows = new List <IntPtr>(); User32.EnumWindows(delegate(IntPtr wnd, IntPtr param) { if (filter(wnd, param)) { // AƱade la ventana a la lista, si pasa el filtro windows.Add(wnd); } // but return true here so that we iterate all windows return(true); }, IntPtr.Zero); return(windows); }
void initCapture(bool capturingWindows) { windows.Clear(); User32.EnumWindowsProc ewp = new User32.EnumWindowsProc(EvalWindow); User32.EnumWindows(ewp, 0); this.capturingWindows = capturingWindows; System.Threading.Thread.Sleep(200); this.SuspendLayout(); this.Visible = false; this.Bounds = GetScreenBounds(); Image img = WindowCapture.CaptureWindow(); pictureBox.Image = img; this.Visible = true; this.ResumeLayout(); string tt = capturingWindows ? lang.GetString("capture_tooltip_windowmode") : lang.GetString("capture_tooltip_regionmode"); tooltip.SetToolTip(pictureBox, tt); }
public static HashSet <IntPtr> findAllWindowsByClass(string sClass, string sWindowCaption = null) { try { _findAllWindowClass = sClass.Trim(); if (sWindowCaption != null) { _findAllWindowTitle = sWindowCaption.Trim(); } windowHandles.Clear(); User32.EnumWindowsProc callBackPtr = GetWindowHandle; User32.EnumWindows(callBackPtr, IntPtr.Zero); } catch (Exception e) { Log.logError("findAllWindowsByClass: " + e.ToString()); } return(windowHandles); }
public void GetWindows() { User32.EnumWindowsProc filterDesktopWindows = delegate(HWND windowHandle, IntPtr lparam) { DesktopWindow desktopWindow = new DesktopWindow(windowHandle); if (desktopWindow.IsRuntimePresent()) { User32.ShowWindow(windowHandle, ShowWindowCommand.SW_RESTORE); desktopWindow.GetInfo(); if (Windows.ContainsKey(desktopWindow.GetDesktopMonitor())) { if (!Windows[desktopWindow.GetDesktopMonitor()].Contains(desktopWindow)) { AddWindow(desktopWindow); } } else { Windows.Add( desktopWindow.GetDesktopMonitor(), new ObservableCollection <DesktopWindow>(new DesktopWindow[] { }) ); AddWindow(desktopWindow); } } return(true); }; User32.EnumWindows(filterDesktopWindows, IntPtr.Zero); foreach (var desktopMonitor in Windows) { Windows[desktopMonitor.Key].CollectionChanged += Windows_CollectionChanged; } }
public static ApplicationWindow FindWindowByCaption(string caption) { ApplicationWindow window = null; var ewp = new User32.EnumWindowsProc((hwnd, lparam) => { var w = ApplicationWindows.GetApplicationWindow(hwnd, lparam); if (w != null && w.Title.Equals(caption, StringComparison.InvariantCulture)) window = w; return (window == null); //continue as long as window == null; }); User32.EnumWindows(ewp, 0); return window; }
private static IEnumerable<ApplicationWindow> FindAltTabableWindows() { List<ApplicationWindow> windows = new List<ApplicationWindow>(); var ewp = new User32.EnumWindowsProc((hwnd, lparam) => { ApplicationWindow window = null; var shouldContinue = ApplicationWindows.Filter(hwnd, lparam, out window); if (window != null) windows.Add(window); return shouldContinue; }); User32.EnumWindows(ewp, 0); return windows.DistinctBy(w => w.hWnd); }