Problem obtaining menu from form.

Class library usage, coding and language questions.
jeffras
Posts: 5
Joined: Mon Nov 06, 2006 5:49 pm

Problem obtaining menu from form.

Post by jeffras » Tue Nov 07, 2006 9:38 pm

I have used the examples of passing the form to the menu constructor on our application and I always receive a menu object with no items (getItemCount() = 0). I can iterate through all of the controls and I have identified the main menu control. Is there a way to create a menu object from the actual control?

Thanks
Jeff

jeffras
Posts: 5
Joined: Mon Nov 06, 2006 5:49 pm

Post by jeffras » Tue Nov 07, 2006 10:00 pm

After more digging at this problem I found that our application uses a non windows menubar (http://www.componentsource.com/products ... mmary.html)

Is there any way to access the menu items of the control or am I out of luck?

Thanks
Jeff

webops
Site Admin
Site Admin
Posts: 349
Joined: Wed Jul 05, 2006 7:44 pm

Post by webops » Wed Nov 08, 2006 8:22 am

Can you see the menu items with RanorexSpy?
If yes, then you can automate the menu with Ranorex.

Jenö Herget
Ranorex Team

jeffras
Posts: 5
Joined: Mon Nov 06, 2006 5:49 pm

Post by jeffras » Wed Nov 08, 2006 4:39 pm

I can only see the menu and not the individual menu items with ranorexspy. It looks like I will not be able to test the menubar with ranorex :0(

Thanks for the help with this.

Jeff

webops
Site Admin
Site Admin
Posts: 349
Joined: Wed Jul 05, 2006 7:44 pm

Post by webops » Wed Nov 08, 2006 8:00 pm

You can also send Keyboard shortcuts to start a menu command.
To start the File New menu you can send:

Code: Select all

// Send ALT + f + n
form.SendKeys("%fn");
or if you want to do it slower:

Code: Select all

// Send ALT + f + n
form.SendKeys("%f");
Application.Sleep(500);
form.SendKeys("n");
Application.Sleep(500);
You can also send global Keyboard events with the function Application.SendKeys();

Jenö Herget
Ranorex Team

CookieMonster
Certified Professional
Certified Professional
Posts: 74
Joined: Mon Aug 14, 2006 7:17 pm
Location: CH

Post by CookieMonster » Fri Nov 24, 2006 8:29 am

Hi Jeffras,

I had the same problems with the DevExpress Controls. If Ranorex can find the main menu control, then you can use a modified version of the DumpTree Example, in my example (ClickChildElement) . But I works only if you can set the Accessibility Name to the submemu items

Best Regards and I hope it helps
Dan

Here the Example: It is a little bit slow but it works for me.

Code: Select all

public void ClickChildElement(Element mnuMainElement, int level, String ctrlName)
        {
            level++;

            int childCount = element.GetChildCount;
            for (int index = 0; index < childCount; index++)
            {
                Element child = element.GetChild(index);
                if (child.Name.Equals(ctrlName))
                {
                    Mouse.ClickElement(child);  
                }
                else
                {
                    GetChildElement(child, level, ctrlName);
                }
            }
        }