| || |
Right click menu disappears when trying to get submenu item details
I am trying to get all the menu and sub menu items from the right click menu of Notepad. While i am doing so, the script runs fine till i reach a menu item which has sub menus. When the menu is reached, i get an error at the line where i am trying to find if there are any submenus. The error displayed is "Object not visible". Can someone help me with why this is happening. The script am using is given below.
The same script seems to work fine with the Main Menu (File,Edit,Format etc)
Window("Notepad").WinEditor("Edit").WinMenu("Conte xtMenu").Select "Undo"
Window("Notepad").WinEditor("Edit").Click 81, 114, micRightBtn
Set menuobj = Window("Notepad").WinEditor("Edit").WinMenu("Conte xtMenu")
menuobj.ExpandMenu = true
GetNamesRec "", menuobj
Function GetNamesRec(itemPath, menuObj)
ret = 0
lbl = menuObj.GetItemProperty(itemPath, "Label")
Reporter.ReportEvent 0, itemPath & " label", lbl
ret = menuObj.GetItemProperty(itemPath, "HasSubMenu")
If ret Then
cnt = menuObj.GetItemProperty(itemPath, "SubMenuCount")
Reporter.ReportEvent 0, itemPath & " sub-menu items", cnt
For n = 1 To cnt
path = menuObj.BuildMenuPath(itemPath, n)
GetNamesRec path, menuObj
Perhaps try with Sendkeys.
In my experience, right click context menus are annoying to work with. Generally it's generally good to develop a set of wrappers for waiting on the menu to appearing, then quickly positioning the mouse inside the context menu to avoid it disappearing once it has appeared. From there you can do your operations.
What has worked for me is to open a window or dialog box, open the menu and slide the window over
the menu and it will not close...
As Kevin said correctly, SendKey should work. At least it worked in my application where we had similar flyover menus (which disappear once you move out the cursor). Do let us know what solution worked for you.
Tags for this Thread