Jump to content
Sign in to follow this  

Get text from context menu - Is it possible?

Recommended Posts

The context menu is called by mouse right click. It contains some options. The list of the options could be different depending of application mode. There is an automation test case checking the list of the options. So the problem is how to get the text from the context menu and to analize it. Autoit window info does not recognize the text. The only things it can see are:

Class:   #32768
Position:   1465, 743
Size:   118, 115
Style:   0x94800000
ExStyle:   0x00000189
Handle:   0x000B054A

The context menu window is accessible by its "[Class: #32768]" and its options could be selected by sending the first letter of the option to the context menu. But the text could not be recognized in any way. Is there any idea how to solve the problem?

Share this post

Link to post
Share on other sites

There is a good working script for accessing a context menu  but not in my case. It does not work and return an empty string for each context menu item. The only difference between this inaccessible context menu and another ones is that my context menu has an icon for each its item. The menu is accessible by its class, all its items could be counted. New items text could be setted, but not displayed. For example the result of the code

For $i =0 To _GUICtrlMenu_GetItemCount($hMenu) - 1
    _GUICtrlMenu_SetItemText($hMenu, $i, "Item" & $i)

For $i = 0 to _GUICtrlMenu_GetItemCount($hMenu) - 1
    $text = _GUICtrlMenu_GetItemText($hMenu, $i, $MF_BYPOSITION)
    ConsoleWrite("This is a text of the item " & $i & ": " & $text & @CRLF)

is: "This is a text of the item0 : Item0 "

     "This is a text of the item0 : Item1 "

     ..... and so on

But the text of the items shown in console is not displayed in the menu. From another hand,  new items could be added and are displayed successfully. Also all menu items are accessible by there first letter (the option could be called by sending the letter to the menu).

Edited by Vitaliy4us

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Create New...