Forum Discussion
Dmitry_Nikolaev
14 years agoStaff
Hi Chris,
We have a sample script that demonstrates how to work with items of the TdxBarManager control. The script identifies items by their captions and clicks them:
function Main_Sample()
{
// ...
var wBarControl = wDockControl.Window("TdxBarControl", "Main Menu");
var itemStr = "&File|&Open Practice...";
if (ClickByCaption(wBarControl.BarManager, itemStr, 0))
{
//The menu item was successfully clicked
}
}
function ClickByCaption(manager, itemStr, level)
{
var tempResult = false;
var currentItem;
Log.LockEvents(1);
var itemArray = itemStr.split("|");
var itemCount = manager.GetItemCount;
for(var itemId = 0; itemId < itemCount; itemId++)
{
currentItem = manager.GetItem(itemId);
if (SameText(currentItem.Caption, itemArray[level]))
{
Runner.CallObjectMethodAsync(currentItem, "Click");
if (level + 1 >= itemArray.length)
{
tempResult = true;
Log.UnlockEvents();
Log.Event("The '" + itemStr + "' menu item was left-clicked.")
return tempResult;
}
else
{
tempResult = ClickByCaption(manager, itemStr, level + 1)
}
}
}
Log.UnlockEvents();
if (!tempResult)
{
Log.Error("The '" + itemStr + "' menu item was not found.")
}
return tempResult;
}
I hope this helps.
Related Content
Recent Discussions
- 7 hours agosimonaferrara
- 15 hours agoSubhraDas
- 2 days agotramuntana