我正在尝试使用Microsoft Lync SDK for Skype for business为所有参与者实现结束当前对话的功能。应该按照以下方式完成的工作:
conversation.End();
但是它仅关闭开始会议的参与者的窗口。 还有另一种方法吗?
答案 0 :(得分:0)
“结束”方法只是让电话会议如您所说。
没有记录到“结束会议”的API。
如果您真的想通过编程方式执行此操作,则需要使用类似Windows Automation的方法来选择“更多选项”按钮,然后选择“结束会议”按钮。
这是使用Windows自动化单击“结束会议”按钮的示例方法。
bool EndMeeting(ConversationWindow window)
{
var conversationWindowElement = AutomationElement.FromHandle(window.InnerObject.Handle);
if (conversationWindowElement == null)
{
return false;
}
AutomationElement moreOptionsMenuItem;
if (GetAutomationElement(conversationWindowElement, out moreOptionsMenuItem, "More options", ControlType.MenuItem))
{
(moreOptionsMenuItem.GetCurrentPattern(ExpandCollapsePattern.Pattern) as ExpandCollapsePattern).Expand();
}
else if (GetAutomationElement(conversationWindowElement, out moreOptionsMenuItem, "More options", ControlType.Button))
{
// in the Office 365 version of lync client, the more options menu item is actually a button
(moreOptionsMenuItem.GetCurrentPattern(InvokePattern.Pattern) as InvokePattern).Invoke();
}
else
{
// didn't find it.
return false;
}
AutomationElement menuOptionAction;
if (!GetAutomationElement(moreOptionsMenuItem, out menuOptionAction, "End Meeting", ControlType.MenuItem))
{
return false;
}
(menuOptionAction.GetCurrentPattern(InvokePattern.Pattern) as InvokePattern).Invoke();
return true;
}
private static bool GetAutomationElement(AutomationElement rootElement, out AutomationElement resultElement, string name, ControlType expectedControlType)
{
Condition propCondition = new PropertyCondition(AutomationElement.NameProperty, name, PropertyConditionFlags.IgnoreCase);
resultElement = rootElement.FindFirst(TreeScope.Subtree, propCondition);
if (resultElement == null)
{
return false;
}
var controlTypeId = resultElement.GetCurrentPropertyValue(AutomationElement.ControlTypeProperty) as ControlType;
if (!Equals(controlTypeId, expectedControlType))
{
return false;
}
return true;
}