Ranorex

Empty SubMenu names

 
Post new topic   Reply to topic    Ranorex Forum Index -> RanorexNet
View previous topic :: View next topic  
Author Message
mweilbacher



Joined: 19 Jan 2007
Posts: 3

PostPosted: Fri Jan 19, 2007 9:18 am    Post subject: Empty SubMenu names
I can get to the menu bar without a problem, but I can't see any names of the menu in the sub menus.

If I use the DumpElementTree technique, all the submenus are there, but they don't have their names either. The menu bar is bases on wtWidgets, but it just wrappers the interface of Win API.

I can't test with RanorexSpy because I can't bring up the submenus and use the drag feature at the same time. Maybe, adding an "always on" feature in Spy would be helpful to help debug this.

Any advice?
Back to top
View user's profile Send private message
admin
Site Admin


Joined: 05 Jul 2006
Posts: 351

PostPosted: Mon Jan 22, 2007 1:39 am    Post subject:
There are a lot of menu implementations from Microsoft and from other companies. Ranorex also has more possibilities to access menu items, please give us the following information:

Is your application a .NET2003, .NET2005 or an older application?
Has your menu bar a control name?
Which Ranorex menu functions do you use?

Can you send us a small sample application with the same menu bar?

Jenö Herget
Ranorex Team
Back to top
View user's profile Send private message Visit poster's website
mweilbacher



Joined: 19 Jan 2007
Posts: 3

PostPosted: Mon Jan 22, 2007 1:54 am    Post subject:
The applicaition is Visual 2003, but uses WxWidgets. www.wxwidgets.org

What I want to do is:
Code: click into code to enlarge
     ret = RxMenuSelectItemText (form, "View","Fullscreen");

The code below is just me iterating seeing that the name of the menu is not valid.

Code: click into code to enlarge
#include "stdafx.h"
#include "RanorexCore.h"

void DumpElementTree(ElementStruct* pElement, int level, HMENU menu=NULL)
{
   level++;
   if (level < 6)
   {
      if (pElement->Role == ROLE_SYSTEM_MENUITEM || pElement->Role == ROLE_SYSTEM_MENUPOPUP ||
         pElement->Role == ROLE_SYSTEM_MENUBAR || pElement->Role == ROLE_SYSTEM_WINDOW)
      {
         if (pElement->Role == ROLE_SYSTEM_MENUBAR )
         {
            menu = GetMenu(pElement->hWnd);
         }
         int childCount = RxElementGetChildCount(pElement);
         for(int index=0;index<childCount;index++)
         {
            int childId=0;
            ElementStruct child;
            HMENU subMenu;
            BOOL ret=RxElementGetChild(pElement, index, &child);
            if( ret == TRUE )
            {
               if (child.Role == ROLE_SYSTEM_MENUITEM || child.Role == ROLE_SYSTEM_MENUPOPUP ||
                  child.Role == ROLE_SYSTEM_MENUBAR)
               {
                  printf("%d",level);
                  for(int j=0;j<level;j++)
                     printf("   ");

                  char szText[256];
                      
                  
                  UINT ID = ::GetMenuItemID(menu,index);
                  ::GetMenuString(menu,index,szText,255,MF_BYPOSITION);
                   
               
                  printf("Index=%d Name=%s Role=%d Value=%s ID=%d %s\n",
                     index,child.Name,child.Role,RxElementGetValue(&child),ID,szText);

               
                  if (ID == 20061)
                  {
                     RxElementDoDefaultAction(&child);
                  }
                  subMenu = GetSubMenu(menu,index);
                  if (level == 3)
                  {
                     subMenu = menu;
                  }
                  DumpElementTree(&child,level,subMenu);
            
               }
            }
         }
      }
   }
}

int _tmain(int argc, _TCHAR* argv[])
{

   if (argc < 2)
   {
      printf("ERROR: Need executable name");
      return 0;
   }
   printf("-------------------------------------\n");
   printf(" Starting application...             \n");
   printf("-------------------------------------\n");
   
   // Starting testapplication
   int ret = RxApplicationStart(argv[1]);
   if ( ret != 0 )
   {
      printf(" ERROR: Cannot start application %s\n",argv[1]);
      exit(1);
   }
 
   HWND form = RxFormFindTitle("Ed", MATCH_SUBSTRING , TRUE, 90000);   
   // Finding form by class name and activate it (timeout=3000 msec)
    if ( form == 0 )
   {
       printf(" ERROR: Application not found\n");
       exit(1);
   }


   printf("Selecting menu items\n");


   ElementStruct elBrowser;
   if (RxControlGetElement (form, &elBrowser))
   {
      DumpElementTree(&elBrowser, 0);
   }

    int i;
    int k;
    int m1;
   int iID;
   int iState;
   char *szName;
   i = RxMenuGetItemCount(form,0);
   for (int j=1;j<=i;j++)
   {
      szName = RxMenuGetItemText(form,j);
      iID =    RxMenuGetItemId (form,j);
      iState =    RxMenuGetItemState  (form,j);
      printf("%d\tNAME: %s\t%d\t%d\n",j, szName, iID, iState);
      k = RxMenuGetItemCount(form,j);
      for (int l=1;l<=k;l++)
      {
         szName = RxMenuGetItemText(form,j,l);
         iID =    RxMenuGetItemId (form,j,l);
         iState =    RxMenuGetItemState  (form,j,l);
         printf("\t%d\tNAME: %s\t%d\t%d\n",l,szName, iID, iState);
      
         m1 = RxMenuGetItemCount(form,j,l);
         for (int m2=1;m2<=m1;m2++)
         {
            szName = RxMenuGetItemText(form,j,l,m2);
            iID =    RxMenuGetItemId (form,j,l,m2);
            iState =    RxMenuGetItemState  (form,j,l,m2);
            printf("\t\t%d\tNAME: %s\t%d\t%d\n",m2,szName, iID, iState);
         }
      }
   }
   ret = RxMenuSelectPosition (form,1,2,-1);
   char* str = RxMenuGetItemText(form,3,2);
     ret = RxMenuSelectItemText (form, "View","Fullscreen");   
 
   RxFormClose(form);
   return 0;
}
Back to top
View user's profile Send private message
admin
Site Admin


Joined: 05 Jul 2006
Posts: 351

PostPosted: Mon Jan 22, 2007 10:36 pm    Post subject:
The following code clicks the menu item "Widget" -> "Set background... Ctrl-B" in the Widgets Demo application.
Code: click into code to enlarge
RxMenuSelectItemText(form, "&Widget", "Set &background...\tCtrl-B");

You should use the "&" and "\t" chars if your menu item has keyboard shortcuts.

Please try and response your results.

Gabor Herget
Ranorex Team
Back to top
View user's profile Send private message Visit poster's website
mweilbacher



Joined: 19 Jan 2007
Posts: 3

PostPosted: Mon Jan 22, 2007 11:44 pm    Post subject: The & does not work
Adding the & does not work.

The text for the menu is actually blank when I use the iteration process sample above.

Is there anyway to specific a position to go to instead of my name? It know the item is there with the correct ID. Just no text.
Back to top
View user's profile Send private message
admin
Site Admin


Joined: 05 Jul 2006
Posts: 351

PostPosted: Tue Jan 23, 2007 12:05 am    Post subject:
mweilbacher wrote:
The text for the menu is actually blank when I use the iteration process sample above.


We used your sample code with the Widgets Demo application and we got the text for all menu items.
We tried both the functions RxMenuSelectItemText() and RxMenuSelectItemPosition() .

mweilbacher wrote:
Is there anyway to specific a position to go to instead of my name?


Yes, RxMenuSelectItemPosition()

Which Ranorex version do you use?
Can you try the Widgets Demo app from www.wxwidgets.org please.

Jenö Herget
Ranorex Team
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Ranorex Forum Index -> RanorexNet All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum