private static List <ControlHandle> GetFromProcess(Process process) { var resultWindowsList = new List <ControlHandle>(); WindowsMethods.EnumWindows((hWnd, _) => { ControlHandle control = hWnd; if (control.IsAppWindow()) { if (process.Id > 0) { var windowProcessId = 0; WindowsMethods.GetWindowThreadProcessId(control, ref windowProcessId); if (windowProcessId == process.Id) { resultWindowsList.Add(control); } } else { resultWindowsList.Add(control); } } return(true); }, 0); return(resultWindowsList); }
public bool IsAppWindow() { if (IsVisibleWindow()) { var stylex = WindowsMethods.GetWindowLong(Handle, WindowsMethods.GWL_ExStyle); if (WindowsMethods.WSEX_ApplicationWindow != (stylex & WindowsMethods.WSEX_ApplicationWindow)) { var style = WindowsMethods.GetWindowLong(Handle, WindowsMethods.GWL_Style); if (IntPtr.Zero.Equals(WindowsMethods.GetWindowLongish(Handle, WindowsMethods.GWL_HWndParent)) && IntPtr.Zero.Equals(WindowsMethods.GetWindow(Handle, WindowsMethods.GW_Owner)) && WindowsMethods.WS_Child != (style & WindowsMethods.WS_Child)) { if (WindowsMethods.WSEX_ToolWindow == (stylex & WindowsMethods.WSEX_ToolWindow)) { return(false); } } else { return(false); } } var windowClass = WindowsMethods.GetClassName(Handle); if (windowClass.Equals("WindowsScreensaverClass") || windowClass.Equals("tooltips_class32")) { return(false); } } else { return(false); } return(true); }
private List <ControlHandle> GetAllControls() { var controlsList = new List <ControlHandle>(); WindowsMethods.EnumChildWindows(Handle, (hWnd, param) => { controlsList.Add(hWnd); return(true); }, 0); return(controlsList); }
public IEnumerable <ControlHandle> GetChildrenWindows() { ControlHandle found = WindowsMethods.FindWindowEx(IntPtr.Zero, IntPtr.Zero, null, null); while (found.Equals(IntPtr.Zero) == false) { if (found.IsVisibleWindow() && found.GetParentOrOwner() == Handle) { yield return(found); } found = WindowsMethods.FindWindowEx(IntPtr.Zero, found, null, null); } }
private bool IsVisibleWindow() { return(WindowsMethods.IsWindow(Handle) && WindowsMethods.IsWindowVisible(Handle)); }
public ControlHandle(IntPtr handle) { Handle = handle; Title = WindowsMethods.GetWindowCaption(handle); Class = WindowsMethods.GetClassName(handle); }
public void Activate() { WindowsMethods.SetForegroundWindow(this); }
private IntPtr GetParentOrOwner() { return(WindowsMethods.GetParent(Handle)); }
private string GetClassName() { return(WindowsMethods.GetClassName(this)); }