Exemplo n.º 1
0
        /// <summary>
        ///     Get the children of the specified interopWindow, from top to bottom. This is not lazy
        ///     This might get different results than the GetChildren
        /// </summary>
        /// <param name="interopWindow">InteropWindow</param>
        /// <param name="forceUpdate">True to force updating</param>
        /// <returns>IEnumerable with InteropWindow</returns>
        public static IEnumerable <IInteropWindow> GetZOrderedChildren(this IInteropWindow interopWindow, bool forceUpdate = false)
        {
            if (interopWindow.HasChildren && interopWindow.HasZOrderedChildren && !forceUpdate)
            {
                return(interopWindow.Children);
            }
            interopWindow.HasZOrderedChildren = true;

            var children = new List <IInteropWindow>();

            // Store it in the Children property
            interopWindow.Children = children;
            foreach (var child in InteropWindowQuery.GetTopWindows(interopWindow))
            {
                child.ParentWindow = interopWindow;
                children.Add(child);
            }
            return(children);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Get all the other windows belonging to the process which owns the specified window
        /// </summary>
        /// <param name="windowToLinkTo">IInteropWindow</param>
        /// <returns>IEnumerable of IInteropWindow</returns>
        public static IEnumerable <IInteropWindow> GetLinkedWindows(this IInteropWindow windowToLinkTo)
        {
            int processIdSelectedWindow = windowToLinkTo.GetProcessId();

            return(InteropWindowQuery.GetTopLevelWindows().Where(window => window.Handle != windowToLinkTo.Handle && window.GetProcessId() == processIdSelectedWindow));
        }