Forum Discussion

Dewayne_Pinion's avatar
Dewayne_Pinion
Contributor
10 years ago

Cannot find popup menu on playback

We are having a heck of a time trying to find and automate some of the controls within our application. It is a .NET app and it has several "popup" menus that users use for navigation. The problem is that we can find these menus with the object spy (point and fix), but on playback we cannot activate the menus, even though we are trying to simulate user actions. Below is some of the code we are trying:

 

Sub ClickProp

THIS NEXT LINE MOST CLOSELY IMITATES USER ACTION, HOWEVER THE POPUP CANNOT BE ACTIVATED
' Aliases.M3_AKShell.AKToolStripDDMenu.ucChangeLevel.tableLayoutPanel1.tvLevel.ClickItem("|Enterprise-Alpha-1|Company-Bravo-2|Property-Victor-3") Dim btn
THE FINDCHILD METHOD FINDS THE CONTROL CORRECTLY Set btn = Sys.Process("M3.AKShell").FindChild("WndClass", "WindowsForms10.SysTreeView32.app.0.21093c0_r39_ad1", 2000) If btn.Exists Then
BTN.CLICK DOES NOT WORK AS IT CANNOT ACTIVATE THE POPUP btn.click Log.Message "Success", "Item Found" Else Log.Error "The control was not found." End If End Sub

 I hope this is clear enough. I really need to figure out how to get this working. Thanks for any and all help :)

  • Ryan_Moran's avatar
    Ryan_Moran
    10 years ago

    So you need to hover the mouse over the parent control, and then click the popup menu?

    If so then you'll need a low level procedure to move the mouse and "hover" over the parent control, wait a few seconds, and then click the menu.

     

    [Edit] You can use .HoverMouse method on the parent control to hover and get the menu to pop up.

  • Ryan_Moran's avatar
    Ryan_Moran
    Valued Contributor

    I don't think you're finding the right control. It's possible the menu is not disposed properly and other exist in memory.

    Try adding additional properties like "Visible" to your .FindChild method call.

     

     

    Sub ClickProp
    
    'THIS NEXT LINE MOST CLOSELY IMITATES USER ACTION, HOWEVER THE POPUP CANNOT BE ACTIVATED
    ' Aliases.M3_AKShell.AKToolStripDDMenu.ucChangeLevel.tableLayoutPanel1.tvLevel.ClickItem("|Enterprise-Alpha-1|Company-Bravo-2|Property-Victor-3")
    
    Dim btn
    
    'THE FINDCHILD METHOD FINDS THE CONTROL CORRECTLY
      Set btn = Sys.Process("M3.AKShell").FindChild(Array("WndClass", "Visible"), Array("WindowsForms10.SysTreeView32.app.0.21093c0_r39_ad1",True), 2000)
      If btn.Exists Then
    'BTN.CLICK DOES NOT WORK AS IT CANNOT ACTIVATE THE POPUP
        btn.click
        Log.Message "Success", "Item Found"
      Else
        Log.Error "The control was not found."
      End If
    
    End Sub

     

    • Dewayne_Pinion's avatar
      Dewayne_Pinion
      Contributor

      Thanks for the reply Ryan,

       

      I have adjusted the code to use the MappedName instead:

       

        Dim btn
         PropArray = Array("MappedName", "Visible")
          ValuesArray = Array("Aliases.M3_AKShell.ToolStripDropDownMenu1.ucChangeLevel.tableLayoutPanel1.tvLevel", True)
      'Sys.Process("M3.AKShell").WinFormsObject("ToolStripDropDownMenu", "", 1).WinFormsObject("ucChangeLevel").WinFormsObject("tableLayoutPanel1").WinFormsObject("tvLevel").Click 10,10
        Set btn = Sys.Process("M3.AKShell").FindChild(PropArray, ValuesArray, 2000)

       Which returns with the control not found. I can switch Visible to False and find the control. However, how do I make the control visible on screen? I am just not sure there is a way to do this currently. Basically the menu works like this (to select a Company for our software to reference). All popups appear on Hover

       

      (Top Menu) Select

      (Pop Up) View Company Menu

      (Pop Up)Tree View on a pop up form that enables us to select company

      • Ryan_Moran's avatar
        Ryan_Moran
        Valued Contributor

        So you need to hover the mouse over the parent control, and then click the popup menu?

        If so then you'll need a low level procedure to move the mouse and "hover" over the parent control, wait a few seconds, and then click the menu.

         

        [Edit] You can use .HoverMouse method on the parent control to hover and get the menu to pop up.