Micro Focus QTP (UFT) Forums
How to get total item in context menu? - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: VB Scripting/Descriptive Programming (https://www.learnqtp.com/forums/Forum-VB-Scripting-Descriptive-Programming)
+--- Thread: How to get total item in context menu? (/Thread-How-to-get-total-item-in-context-menu)



How to get total item in context menu? - Star - 07-28-2009

Hi,

I have to automate context menu, in which we right click on an object and menu opens. How can we get all the childs from this menu?

Thanks,


RE: How to get total item in context menu? - Saket - 07-28-2009

I think QTP does not support context menu, but yes there can be different ways of handling operations on it using QTP.
If you can tell us the exact scenario what you want to do then may be I can help you.


RE: How to get total item in context menu? - Star - 07-29-2009

I have a Tree view, and the root node of Tree View has context menu. In which we right click on node of tree view and menu opens, I have to get count of items in that menu. and also i have to get their labels. How can i do that?
Let me know, if my question is still not clear?


RE: How to get total item in context menu? - Andriana - 09-11-2009

Hi,

I am not sure what you want to get. But may the next part of code will help you.

Open "My Documents" and run (<Item 5> in my case has submenu):

Code:
strWin = "My Documents"
Window("regexpwndtitle:="&strWin).Activate
wait 1
Window("regexpwndtitle:="&strWin).WinListView("regexpwndclass:=SysListView32").Select 0,micRightBtn
wait 2
Set oContMenu = Window("regexpwndtitle:="&strWin).WinObject("regexpwndclass:=SHELLDLL_DefView").WinMenu("menuobjtype:=3")
nCnt = oContMenu.GetItemProperty("", "SubMenuCount")
strMenu = oContMenu.GetItemProperty("<Item 5>", "Label") '// will return the menu string
Window("regexpwndtitle:="&strWin).WinListView("regexpwndclass:=SysListView32").Select 0,micRightBtn
bRes = oContMenu.GetItemProperty("<Item 5>", "HasSubMenu") '// if it has sub menu
wait 2
If bRes Then
    Window("regexpwndtitle:="&strWin).WinListView("regexpwndclass:=SysListView32").Select 0,micRightBtn
    wait 2
    oContMenu.Select strMenu
    nCnt2 = oContMenu.GetItemProperty("<Item 5>", "SubMenuCount")
    strMenu2 = oContMenu.GetItemProperty("<Item 5>;<Item 1>", "Label") '// will return the menu string
End If