Пример #1
0
        private void AddChildNode(IntPtr RootParent, TreeNode ParentNode, IntPtr ParentWindow)
        {
            //string Name;
            IntPtr Child = NM.GetWindow(ParentWindow, NM.GetWindowEnum.CHILD);

            if (Child != IntPtr.Zero)
            {
                if (NM.IsWindowVisible(Child))
                {
                    GetIdentity(RootParent, Child);
                    string APEType = GetAPEType(m_Identity);

                    //Name = GetName(RootParent, Child);
                    TreeNode ChildNode = ParentNode.Nodes.Add(RootParent.ToString() + ":" + Child.ToString(), APEType + " " + m_Identity.Name + " [" + Child.ToString() + "]");
                    AddChildNode(RootParent, ChildNode, Child);
                }

                IntPtr Sibling = Child;
                do
                {
                    Sibling = NM.GetWindow(Sibling, NM.GetWindowEnum.HWNDNEXT);
                    if (Sibling != IntPtr.Zero)
                    {
                        if (NM.IsWindowVisible(Sibling))
                        {
                            GetIdentity(RootParent, Sibling);
                            string APEType = GetAPEType(m_Identity);

                            //Name = GetName(RootParent, Sibling);
                            TreeNode SiblingNode = ParentNode.Nodes.Add(RootParent.ToString() + ":" + Sibling.ToString(), APEType + " " + m_Identity.Name + " [" + Sibling.ToString() + "]");
                            AddChildNode(RootParent, SiblingNode, Sibling);
                        }
                    }
                }while (Sibling != IntPtr.Zero);
            }
        }
Пример #2
0
        private void SingleClickTabInternal(int tabIndex, string tabName, MouseButton button)
        {
            if (SelectedTabText() == tabName)
            {
                GUI.Log("Ensure tab " + tabName + " is selected in the " + Identity.Description, LogItemType.Action);
                return;
            }

            bool      multiLine    = MultiLine();
            Rectangle tabRectangle = TabRectangle(tabIndex);

            NM.tagRect tabRect;
            NM.GetClientRect(Identity.Handle, out tabRect);
            int width = tabRect.right;

            // multiline means no scroll button
            if (!multiLine)
            {
                IntPtr upDownControl = NM.GetWindow(Identity.Handle, NM.GetWindowCmd.GW_CHILD);

                while (true)
                {
                    if (upDownControl == IntPtr.Zero)
                    {
                        break;
                    }

                    string className = NM.GetClassName(upDownControl);

                    if (className == "msctls_updown32")
                    {
                        break;
                    }

                    upDownControl = NM.GetWindow(upDownControl, NM.GetWindowCmd.GW_HWNDNEXT);
                }

                if (upDownControl != IntPtr.Zero)
                {
                    // work out if we need to scroll the tab into view
                    NM.tagRect scrollButtonsRect;
                    NM.GetClientRect(upDownControl, out scrollButtonsRect);

                    width = tabRect.right - scrollButtonsRect.right;

                    GUIButton scrollTabButton = new GUIButton(ParentForm, "Scroll button", new Identifier(Identifiers.TechnologyType, "Windows Native"), new Identifier(Identifiers.Handle, upDownControl));

                    while (true)
                    {
                        if (tabRectangle.X < 0)
                        {
                            GUI.Log("Click " + Identity.Description + " left button", LogItemType.Action);
                            scrollTabButton.SingleClickInternal(5, 5, MouseButton.Left, MouseKeyModifier.None);
                        }
                        else if (tabRectangle.X > width)
                        {
                            GUI.Log("Click " + Identity.Description + " right button", LogItemType.Action);
                            scrollTabButton.SingleClickInternal(scrollButtonsRect.right - 5, 5, MouseButton.Left, MouseKeyModifier.None);
                        }
                        else
                        {
                            break;
                        }

                        tabRectangle = TabRectangle(tabIndex);
                    }
                }
            }

            GUI.Log("Select tab " + tabName + " in " + Identity.Description, LogItemType.Action);
            int x = tabRectangle.X + (tabRectangle.Width / 2);
            int y = tabRectangle.Y + (tabRectangle.Height / 2);

            if (!multiLine)
            {
                if (x > width - 1)
                {
                    x = width - 2;
                }
            }
            base.SingleClickInternal(x, y, button, MouseKeyModifier.None);

            // Confirm the expected tab has been selected
            Stopwatch timer = Stopwatch.StartNew();

            while (true)
            {
                if (timer.ElapsedMilliseconds > GUI.GetTimeOut())
                {
                    throw new Exception("Failed to select tab " + tabName);
                }

                if (SelectedTabText() == tabName)
                {
                    break;
                }

                Thread.Sleep(15);
            }
        }
Пример #3
0
        private void SingleClickTabInternal(int tabIndex, string tabName, MouseButton button)
        {
            if (SelectedTabText() == tabName)
            {
                GUI.Log("Ensure tab " + tabName + " is selected in the " + Identity.Description, LogItemType.Action);
                return;
            }

            int actualTabIndex = tabIndex + TabOffset;

            bool      multiLine    = MultiLine();
            Rectangle tabRectangle = TabRectangle(actualTabIndex);

            NM.tagRect tabRect;
            NM.GetClientRect(Identity.Handle, out tabRect);
            int width = tabRect.right;

            // multiline means no scroll button (only top and bottom placement support a scroll button)
            if (!multiLine)
            {
                //We may need to scroll
                if (Identity.TechnologyType == "Windows Forms (WinForms)" || (Identity.TechnologyType == "Windows ActiveX" && Identity.TypeName == "TabStrip"))
                {
                    IntPtr upDownControl = NM.GetWindow(Identity.Handle, NM.GetWindowCmd.GW_CHILD);

                    while (true)
                    {
                        if (upDownControl == IntPtr.Zero)
                        {
                            break;
                        }

                        string className = NM.GetClassName(upDownControl);

                        if (className == "msctls_updown32" || className == "msvb_lib_updown")
                        {
                            break;
                        }

                        upDownControl = NM.GetWindow(upDownControl, NM.GetWindowCmd.GW_HWNDNEXT);
                    }

                    if (upDownControl != IntPtr.Zero)
                    {
                        // work out if we need to scroll the tab into view
                        NM.tagRect scrollButtonsRect;
                        NM.GetClientRect(upDownControl, out scrollButtonsRect);

                        width = tabRect.right - scrollButtonsRect.right;

                        GUIButton scrollTabButton = new GUIButton(ParentForm, "Scroll button", new Identifier(Identifiers.TechnologyType, "Windows Native"), new Identifier(Identifiers.Handle, upDownControl));

                        while (true)
                        {
                            if (tabRectangle.X < 0)
                            {
                                GUI.Log("Click " + Identity.Description + " left button", LogItemType.Action);
                                scrollTabButton.SingleClickInternal(5, 5, MouseButton.Left, MouseKeyModifier.None);
                            }
                            else if (tabRectangle.X > width)
                            {
                                GUI.Log("Click " + Identity.Description + " right button", LogItemType.Action);
                                scrollTabButton.SingleClickInternal(scrollButtonsRect.right - 5, 5, MouseButton.Left, MouseKeyModifier.None);
                            }
                            else
                            {
                                break;
                            }

                            tabRectangle = TabRectangle(actualTabIndex);
                        }
                    }
                }
                else if (Identity.TechnologyType == "Windows ActiveX" && Identity.TypeName == "SftTabs")
                {
                    tabRectangle = TabRectangle(actualTabIndex);

                    while (tabRectangle.Width == 0 || tabRectangle.Height == 0)
                    {
                        int visibleTab = SftTabVisibleTab();
                        if (actualTabIndex < visibleTab)
                        {
                            SftTabClickLeftUp();
                        }
                        else
                        {
                            SftTabClickRightDown();
                        }
                        tabRectangle = TabRectangle(actualTabIndex);
                    }
                }
                else
                {
                    throw GUI.ApeException("The " + Description + " is of an unsupported type " + Identity.TypeNameSpace + "." + Identity.TypeName);
                }
            }

            GUI.Log("Select tab " + tabName + " in the " + Identity.Description, LogItemType.Action);
            int x = tabRectangle.X + (tabRectangle.Width / 2);
            int y = tabRectangle.Y + (tabRectangle.Height / 2);

            if (!multiLine)
            {
                if (x > width - 1)
                {
                    x = width - 2;
                }
            }
            base.SingleClickInternal(x, y, button, MouseKeyModifier.None);

            // Confirm the expected tab has been selected
            Stopwatch timer = Stopwatch.StartNew();

            while (true)
            {
                if (SelectedTabText() == tabName)
                {
                    break;
                }

                if (timer.ElapsedMilliseconds > GUI.GetTimeOut())
                {
                    throw GUI.ApeException("Failed to select tab " + tabName);
                }

                Thread.Sleep(15);
            }
        }