Example #1
0
        /// <summary>
        /// Click on an appPath via the gui model and/or a guiPath via
        /// Active Accessibility.
        /// If only the context is not null, it's value is used.
        /// If the context is null, the model root is used with appPath.
        /// The appPath is applied first, if any, then the guiPath.
        /// If there is no context or appPath, the guiPath is used.
        /// </summary>
        /// <param name="context">Model node to start appPath from or null</param>
        /// <param name="appPath">the appPath to a control or null</param>
        /// <param name="guiPath">the guiPath to click or null</param>
        /// <param name="leftClick">true if left-click, false on right-click</param>
        /// <returns>true if the path was valid and a click attempted</returns>
        private bool click(XmlNode context, string appPath, string guiPath, bool leftClick)
        {
            // if only a context, select it to click on.
            XmlPath xp = m_GuiModel.selectToXmlPath(context, appPath);

            if (xp == null || !xp.isValid())
            {
                return(false);
            }
            AccessibilityHelper ah = findInGui(xp, guiPath);

            if (ah == null)
            {
                return(false);
            }
            if (leftClick)
            {
                ah.SimulateClickRelative(10, 10);
            }
            else
            {
                ah.SimulateRightClickRelative(10, 10);
            }
            return(true);
        }
Example #2
0
 private string ClickPath(AccessibilityHelper ah, GuiPath gpath)
 {
     //bool forAll = false;
     //bool clickParent = false;
     //AccessibilityHelper child;
     //if (m_for != null && "all" == (string)m_for) forAll = true;
     if (1 == m_logLevel)
     {
         m_log.paragraph(makeNameTag() + "Click starting path from &quot;" + ah.Role + ":" + ah.Name + "&quot;");
     }
     ah = gpath.FindInGui(ah, this);
     if (ah != null)
     {
         if (1 == m_logLevel)
         {
             m_log.paragraph(makeNameTag() + "Clicking last pair in path");
         }
         int j;
         for (j = 0; j < m_repeat; j++)
         {                  // click 10 pixels from the left edge - see below
             if (m_side == "right")
             {
                 ah.SimulateRightClickRelative(m_dx, m_dy);
             }
             else
             {
                 ah.SimulateClickRelative(m_dx, m_dy);
             }
             // when @wait="no" don't wait at all between repeated clicks
             if (m_wait)
             {
                 Thread.Sleep(400);                             // wait a while eg. let menus open, etc.
             }
         }
         m_finished = true;                 // tell do-once it's done
     }
     else
     {
         return(m_message);
     }
     return("");
 }