The classes MenuStrip, ToolStrip and StatusStrip are new in Visual Studio 2005 and does not exist in Visual Studio 2003.
(We extended the RanorexNet documentation with this information for the next version.)
Visual Studio 2003 applications have an old style menu bar with menu handle, not a menu strip.
You can automate such a menu as follows:
Code: click into code to enlarge
Menu menu = new Menu(form);
if (menu != null)
{
// Get the item count of the first submenu
ret = menu.GetItemCount(1);
Console.WriteLine(" GetItemCount(1)={0}", ret);
// Get the text of the second menu item of the first submenu
itemText = menu.GetItemText(1, 2);
Console.WriteLine(" GetItemText(1,2)={0}", itemText);
// Select a menu item
ret = menu.SelectItemText("Submenu2", "Submenu2Item1");
}
The following code sample dumps out all menu item of the submenu 1 and 2.
Code: click into code to enlarge
for (int submenu = 1; submenu <= 2; submenu++)
{
Int32 itemCount = menu.GetItemCount(submenu);
for (int itemPosition = 1; itemPosition <= itemCount; itemPosition++)
{
itemText = menu.GetItemText(submenu, itemPosition);
Console.WriteLine(" Item({0})={1}", itemPosition, itemText);
}
}
Jenö Herget
Ranorex Team |