Example #1
0
        private void WindowTree_AfterSelect(object sender, TreeViewEventArgs e)
        {
            m_ControlKey         = true;
            LocateButton.Enabled = true;

            string[] SplitCharacters = { ":" };
            string[] Handles         = WindowTree.SelectedNode.Name.Split(SplitCharacters, StringSplitOptions.None);

            IntPtr Parent = new IntPtr(int.Parse(Handles[0]));
            IntPtr Handle = new IntPtr(int.Parse(Handles[1]));

            if (NM.IsWindow(Handle))
            {
                PopulatePropertyListbox(Parent, Handle);
            }
            else
            {
                PropertyListbox.Items.Clear();
                if (m_CurrentAttached.Key.HasExited)
                {
                    WinformsProcessesCombobox.SelectedIndex = 0;
                    Populate();
                }
                else
                {
                    BuildTree();
                }
            }
        }
Example #2
0
 /// <summary>
 /// Get the forms window state
 /// </summary>
 /// <returns>The window state</returns>
 private string FormWindowState()
 {
     if (NM.IsWindow(Identity.Handle))
     {
         if (NM.IsWindowVisible(Identity.Handle))
         {
             // Get the windows current state
             GUI.m_APE.AddFirstMessageFindByHandle(DataStores.Store0, Identity.ParentHandle, Identity.Handle);
             GUI.m_APE.AddQueryMessageReflect(DataStores.Store0, DataStores.Store1, "WindowState", MemberTypes.Property);
             GUI.m_APE.AddQueryMessageReflect(DataStores.Store1, DataStores.Store2, "ToString", MemberTypes.Method);
             GUI.m_APE.AddRetrieveMessageGetValue(DataStores.Store2);
             GUI.m_APE.SendMessages(EventSet.APE);
             GUI.m_APE.WaitForMessages(EventSet.APE);
             //Get the value(s) returned MUST be done straight after the WaitForMessages call
             string windowState = GUI.m_APE.GetValueFromMessage();
             return(windowState);
         }
         else
         {
             throw new Exception("Form is not visible");
         }
     }
     else
     {
         throw new Exception("Form does not exist");
     }
 }
Example #3
0
        private void LocateButton_Click(object sender, EventArgs e)
        {
            if (WindowTree.SelectedNode != null)
            {
                string[] SplitCharacters = { ":" };
                string[] Handles         = WindowTree.SelectedNode.Name.Split(SplitCharacters, StringSplitOptions.None);

                IntPtr ParentHandle = new IntPtr(int.Parse(Handles[0]));
                IntPtr Handle       = new IntPtr(int.Parse(Handles[1]));

                if (NM.IsWindow(Handle) && NM.IsWindowVisible(Handle))
                {
                    if (ParentHandle == IntPtr.Zero)
                    {
                        NM.BringWindowToTop(Handle);
                    }
                    else
                    {
                        NM.BringWindowToTop(ParentHandle);
                    }

                    NM.tagRect area = Display.GetWindowRectangleDIP(Handle);

                    IntPtr hWindowDC     = NM.GetDC(IntPtr.Zero);
                    IntPtr hRectanglePen = NM.CreatePen(NM.PenStyle.PS_SOLID, 3, (uint)ColorTranslator.ToWin32(Color.Red));
                    IntPtr hPrevPen      = NM.SelectObject(hWindowDC, hRectanglePen);
                    IntPtr hPrevBrush    = NM.SelectObject(hWindowDC, NM.GetStockObject(NM.StockObjects.HOLLOW_BRUSH));

                    for (int i = 0; i < 3; i++)
                    {
                        NM.Rectangle(hWindowDC, area.left, area.top, area.right, area.bottom);
                        Thread.Sleep(300);
                        ClearHighlight(area);
                        if (i < 2)
                        {
                            Thread.Sleep(300);
                        }
                    }

                    NM.SelectObject(hWindowDC, hPrevPen);
                    NM.SelectObject(hWindowDC, hPrevBrush);
                    NM.ReleaseDC(Handle, hWindowDC);
                }
                else
                {
                    BuildTree();
                }
            }

            WindowTree.Focus();
        }
Example #4
0
        /// <summary>
        /// Closes the form by click the 'x' in the top right hand corner of the form
        /// </summary>
        public void Close()
        {
            if (NM.IsWindow(Identity.Handle))
            {
                if (NM.IsWindowVisible(Identity.Handle))
                {
                    if (NM.IsIconic(Identity.Handle))
                    {
                        throw new Exception("Can not close the window as it is minimised");
                    }

                    GUI.m_APE.AddFirstMessageGetTitleBarItemRectangle(Identity.Handle, NM.TitleBarStateElement.Close);
                    GUI.m_APE.SendMessages(EventSet.APE);
                    GUI.m_APE.WaitForMessages(EventSet.APE);
                    //Get the value(s) returned MUST be done straight after the WaitForMessages call
                    NM.StateSystem State  = (NM.StateSystem)GUI.m_APE.GetValueFromMessage();
                    int            Top    = GUI.m_APE.GetValueFromMessage();
                    int            Left   = GUI.m_APE.GetValueFromMessage();
                    int            Bottom = GUI.m_APE.GetValueFromMessage();
                    int            Right  = GUI.m_APE.GetValueFromMessage();

                    // Check the close button is actually displayed
                    if (State != NM.StateSystem.STATE_SYSTEM_NORMAL && State != NM.StateSystem.STATE_SYSTEM_PRESSED)
                    {
                        throw new Exception("Can not close the window as the close button is in state '" + State.ToString() + "'");
                    }

                    NM.tagRect WindowRect;
                    NM.GetWindowRect(Identity.Handle, out WindowRect);

                    int X = Left + ((Right - Left) / 2) - WindowRect.left;
                    int Y = Top + ((Bottom - Top) / 2) - WindowRect.top;

                    Input.Block(Identity.ParentHandle, Identity.Handle);
                    try
                    {
                        GUI.Log("Close the " + Identity.Description, LogItemType.Action);
                        base.SingleClickInternal(X, Y, MouseButton.Left, MouseKeyModifier.None);

                        //Wait for the window to disappear
                        base.WaitForControlToNotBeVisible();
                    }
                    finally
                    {
                        Input.Unblock();
                    }
                }
            }
        }
Example #5
0
        /// <summary>
        /// Waits for the specified control to not be visible or for its parent form to be disabled
        /// </summary>
        /// <returns>True if the control is not visible, false if its visible but its parent form is disabled</returns>
        public bool WaitForControlToNotBeVisible()
        {
            bool returnValue;
            //Wait for the control to not be visible
            Stopwatch timer = Stopwatch.StartNew();

            while (true)
            {
                if (timer.ElapsedMilliseconds > GUI.m_APE.TimeOut)
                {
                    throw GUI.ApeException(this.Description + " failed to become nonvisible");
                }

                if (!this.IsVisible)
                {
                    returnValue = true;
                    break;
                }

                if (this is GUIForm)
                {
                    if (!this.IsEnabled)
                    {
                        returnValue = false;
                        break;
                    }
                }
                else
                {
                    if (!ParentForm.IsEnabled)
                    {
                        returnValue = false;
                        break;
                    }
                }

                Thread.Sleep(15);
            }

            // Small sleep to let focus switch
            Thread.Sleep(20);
            if (NM.IsWindow(Handle))
            {
                Input.WaitForInputIdle(Handle, GUI.m_APE.TimeOut);
            }
            return(returnValue);
        }