C# 通过 Skype4COM.dll COM API 控制 Skype
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/627517/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Controlling Skype via its Skype4COM.dll COM API
提问by kenny
I'm working with the Skype4COM.dll COM APIusing C# and it works very well for all of the communication functionality we need. We are trying to put an easier to use interface on top of Skype that is baked into our application.
我正在使用 C# 处理Skype4COM.dll COM API,它非常适合我们需要的所有通信功能。我们正在尝试在 Skype 之上放置一个更易于使用的界面,该界面已嵌入到我们的应用程序中。
My trouble lies in controlling or disabling which Skype windows to use and not use. The only Skype window I believe I'll need is the Skype video phone/conference window. I would like to hide and control every other window that Skype can present. I would even like to disable the incoming call dialog window that pops up on incoming calls, since we'll be presenting our own answer prompt. I'm happy with the API except window management.
我的麻烦在于控制或禁用要使用和不使用的 Skype 窗口。我相信我唯一需要的 Skype 窗口是 Skype 视频电话/会议窗口。我想隐藏和控制 Skype 可以显示的所有其他窗口。我什至想禁用来电时弹出的来电对话窗口,因为我们将呈现我们自己的应答提示。除了窗口管理之外,我对 API 很满意。
With the API, I can see how to enable Windows, but I can't seem to figure out how to hide them, short of hacking a windows message to the Skype app. Am I missing something?
使用 API,我可以看到如何启用 Windows,但我似乎无法弄清楚如何隐藏它们,除非向 Skype 应用程序发送 Windows 消息。我错过了什么吗?
Thanks for your assistance, Kenny
感谢您的帮助,肯尼
采纳答案by kenny
Poking around a bit we found that you can send 'Skype Commands' via
仔细研究了一下,我们发现您可以通过以下方式发送“Skype 命令”
skypeobj.SendCommand ( Command cmd );
That works pretty well for most of what we need. Here is a reference on the Skype developer site:
这对于我们需要的大部分内容都非常有效。这是Skype 开发人员网站上的参考:
Some code:
一些代码:
void _SendSkypeCommand ( string cmdToSend )
{
Command cmdSkype = new Command ();
cmdSkype.Blocking = true;
cmdSkype.Timeout = 2000;
cmdSkype.Command = cmdToSend;
Trace.WriteLineIf ( _TracingDetailed, string.Format ( "skype command sent '{0}'", cmdToSend ) );
_skype.SendCommand ( cmdSkype );
}
void _hideSkypeWindows ()
{
_SendSkypeCommand ( "SET SILENT_MODE ON" );
_SendSkypeCommand ( "SET WINDOWSTATE HIDDEN" );
}
回答by casperOne
Unfortunately, the interface doesn't actually give you control over the actual windows, only methods to display and modify them (through wrappers).
不幸的是,界面实际上并没有让您控制实际的窗口,只有显示和修改它们的方法(通过包装器)。
As you said, you will have to get the handle of the window somehow and then send a message to hide it.
正如您所说,您必须以某种方式获取窗口的句柄,然后发送消息以隐藏它。
回答by Steven Du
I have same problem, and the
我有同样的问题,并且
_SendSkypeCommand ( "SET SILENT_MODE ON" );
_SendSkypeCommand ( "SET SILENT_MODE ON" );
has been broken, as it is said on this post: http://devforum.skype.com/t5/Desktop-API/How-to-keep-hidden-Skype-UI-using-Skype4COM/td-p/12338
已经坏了,正如这篇文章所说:http: //devforum.skype.com/t5/Desktop-API/How-to-keep-hidden-Skype-UI-using-Skype4COM/td-p/12338
My solution is make skype UI invisible by moving it's window out of display area.
我的解决方案是通过将其窗口移出显示区域来使 Skype UI 不可见。
Now code:
现在代码:
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
public static extern IntPtr FindWindowEx(IntPtr parentHandle, IntPtr childAfter, string lclassName, string windowTitle);
[DllImport("user32.dll", SetLastError = true)]
internal static extern bool MoveWindow(IntPtr hWnd, int X, int Y, int nWidth, int nHeight, bool bRepaint);
IntPtr hwnd = FindWindowEx(IntPtr.Zero, IntPtr.Zero, "tSkMainForm", null);//find skype window
MoveWindow(hwnd, 2300, 2300, 300, 400, true);