Forum Discussion
YMinaev
Staff
14 years agoHi,
Normally (in Win32 applications), menus are not individual objects, they are always assigned to a window. You can check whether a menu item is enabled by using the script below.
Normally (in Win32 applications), menus are not individual objects, they are always assigned to a window. You can check whether a menu item is enabled by using the script below.
function isMenuItemEnabled(menu, item)
{
var currentItem = item.match(/(\w*)\|/);
if(!currentItem)
{
currentItem = item;
item = "";
}
else
{
item = item.replace(currentItem[0], "");
currentItem = currentItem[1];
}
for(var i = 0; i < menu.Count; i++)
{
var cur = menu.Items(i);
if(cur.Caption != currentItem) continue;
if(item != "")
if(cur.SubMenu) return isMenuItemEnabled(cur.SubMenu, item);
else return false;
return cur.Enabled;
}
return false;
}
function sample()
{
var menu = Sys.Process("notepad").Window("Notepad").MainMenu;
Log.Message(isMenuItemEnabled(menu, "Edit|Cut"));
}