Results 1 to 3 of 3
  1. #1

    Right Clicking Node on Tree view and pop up menu


    I was wondering if anyone has ever ran into the problem of trying to right click on a node of a tree view, and select a menu option from the popup menu.

    I am trying to right a function that will take in the tree path to right click, then the menu path to select, but I cannot figure out how to do the menu path string. It seems that I am clicking an X & Y axis point in the pop up, not a path to the selection.

    <font class="small">Code:</font><hr /><pre>
    //first we right click the menu option User&gt;&gt;Jack
    //Now I want to select my option from the pop up menu User&gt;&gt; Change Password
    p1.WinFormsObject("ToolStripDropDownMenu", "", 1).Click(70, 16);
    </pre><hr />

    Is there any way I can send the "ToolStripDropDownMenu" a string for the menu path "|USER|CHANGE PASSWORD" , instead of giving the x and y?

  2. #2

    Re: Right Clicking Node on Tree view and pop up menu


    It looks like the control doesn't own the menu. I suggest that you use the following function to click the menu's items:

    <font class="small">Code:</font><hr /><pre>
    function ClickMenuItem(menu, path)
    var i, items, item, found, x, y, point;

    items = path.split("|");

    // Find the menu item to click
    found = false;
    for (i = 0; i &lt; menu.Items.Count; i++)
    item = menu.Items.Item(i);
    if (item.Text.OleValue == items[0])
    found = true;

    if (!found)
    Log.Error("The '" + items[0] + "' menu item was not found");
    return false;

    // Calculate the menu item's screen coordinates and click the found point
    point = menu.PointToScreen(item.Bounds.Location);
    x = point.X + item.Bounds.Width / 2;
    y = point.Y + item.Bounds.Height / 2;
    Sys.Desktop.MouseDown(VK_LBUTTON, x, y);
    Sys.Desktop.MouseUp(VK_LBUTTON, x, y);

    // Proceed to the next item in the path
    if (items.length &gt; 1)
    if (!ClickMenuItem(item.DropDown, items.slice(1).join("|")))
    return false;

    return true;
    var menu = p1.WinFormsObject("ToolStripDropDownMenu", "", 1);

    ClickMenuItem(menu, "USER|CHANGE PASSWORD");
    ...</pre><hr />

    Does this help?
    Jared - AQA Support

  3. #3

    Re: Right Clicking Node on Tree view and pop up menu

    I actually took a variation of this function you listed and worked it into our automation framework.

    Thank you very much for your help.



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
BetaSoft Inc.
All times are GMT -8. The time now is 05:57 PM.

Copyright BetaSoft Inc.