Sys.Process("WINWORD").Form("test.docx -").Window("FullpageUIHost").Window("NetUIHWND").Pane("Backstage view").Client(0).Pane("Print").Grouping("Print").Grouping(0).Client(0).ComboBox("Which Printer")
Is implemented differently than the actual list of items in the ComboBox. Below is what I get when I use the object browser on an individual combobox item:
Sys.Process("WINWORD").Window("Net UI Tool Window", "", 1).Panel("Which Printer").List("Which Printer").Client(0).ListItem("My Printer")
The problem is that for the life of me I cannot get ClickItem() on the combobox to actually change the selection, either by name or index. I have tried MSAA both in the new mode and in the legacy mode but to no avail. I have tried giving focus to the combobox, calling click() on it first to open it, etc... but nothing I do actually allows me to intelligently change the box. I am theorizing that I could probably open it and then walk each item looking for the string I want to select, but this is a really kludge solution.
Can anyone shed some light on this dilema?
Thanks,
Jim
function ClickItemMain()
{
var wComboBox = Sys.Process("WINWORD").Form("Document1 -").Window("FullpageUIHost").Window("NetUIHWND").Pane("Backstage view").Client(0).Pane("Print").Grouping("Print").Grouping(0).Client(0).ComboBox("Which Printer");
var strItem = "Microsoft XPS Document Writer";
if (ClickItem(wComboBox, strItem))
{
Log.Message("The '" + strItem + "' combo-box item was successfully clicked.");
}
}
function ClickItem(wCombo, strItem)
{
Log.LockEvents(1);
//Open dropdown
wCombo.Button("Open").Click();
var p = getProcess(wCombo);
//Get dropdown
var wDropdown = p.Window("Net UI Tool Window", "", 1).Panel("Which Printer").List("Which Printer").Client(0);
var wlistItem = wDropdown.FindChild("Caption", strItem)
if (wlistItem.Exists)
{
//Click item
wlistItem.Click();
Log.UnLockEvents();
Log.Event("The '" + strItem + "' combo-box item was clicked.");
return true;
}
else
{
Log.UnLockEvents();
Log.Error("The '" + strItem + "' combo-box item was not found.");
return false;
}
}
function getProcess(obj)
{
while (!IsSupported(obj, "ProcessName"))
{
obj = obj.Parent;
}
return obj;
}