当人类拿起电话(例如: open Notepad
)时,我会立即添加动作。我应该使用哪个event
?我尝试了很多,events
但ManagerConnection
找不到解决方案。
编辑:我将执行与屏幕截图相同的功能(当人们拿起电话时,做一些事情)。ADAT 程序有这个功能,也将有。
编辑2:我找到了解决方案。示例代码:
订阅活动
managerConnection.NewState += new NewStateEventHandler(Monitoring_NewState);
private void Monitoring_NewState(object sender, NewStateEvent e)
{
string state = e.State;
string callerID = e.CallerId;
if ((state == "Ringing") | (e.ChannelState == "5"))
{
String connectedLineNum;
String connectedLineName;
Dictionary<String, String> attributes = e.Attributes;
attributes.TryGetValue("connectedlinenum", out connectedLineNum);
attributes.TryGetValue("connectedlinename", out connectedLineName);
// "callerID" - called phone number
// "connectedLineNum" - calling phone number
// CallIn. Incoming call
}
else if ((state == "Ring") | (e.ChannelState == "4"))
{
// CallOut. Outcoming call
}
else if ((state == "Up") | (e.ChannelState == "6"))
{
String connectedLineNum;
String connectedLineName;
Dictionary<String, String> attributes = e.Attributes;
attributes.TryGetValue("connectedlinenum", out connectedLineNum);
attributes.TryGetValue("connectedlinename", out connectedLineName);
// "callerID" - called phone number
// "connectedLineNum" - calling phone number
// human lifted up the phone right now
}
}