skype4comlib 创建好友列表
skype4comlib Create List of Friends
我正在尝试获取所有在线 Skype 好友的列表,并将其放入名为 lst1
的 listbox
中。
我还试图让我的工具响应一些命令,比如如果有人向我发送 !news
,它会向他们发送我在代码中设置的文本。
这是我到目前为止尝试过的方法,我只是在玩弄代码以了解如何使用 skype4comlib
。
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using MetroFramework;
using MetroFramework.Forms;
using MetroFramework.Components;
using SKYPE4COMLib;
using System.Threading;
namespace betaskypetool
{
public partial class Form1 : MetroForm
{
#region Definitions
Skype Merk = new Skype();
private int count = 1;
#endregion
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void metroButton1_Click(object sender, EventArgs e)
{
try
{
this.Merk.Attach(5, true);
MessageBox.Show("You are now connected enjoy!", "Tutorial Skype Tool!");
}
catch (Exception)
{
MessageBox.Show("Failed To Connect?\n Be Sure Skype Is Open!", "Tutorial Skype Tool!");
}
}
private void metroButton2_Click(object sender, EventArgs e)
{
this.Merk.CurrentUserStatus = TUserStatus.cusOnline;
}
private void metroButton3_Click(object sender, EventArgs e)
{
this.Merk.CurrentUserStatus = TUserStatus.cusDoNotDisturb;
}
private void metroButton4_Click(object sender, EventArgs e)
{
this.Merk.CurrentUserStatus = TUserStatus.cusAway;
}
private void metroButton5_Click(object sender, EventArgs e)
{
this.Merk.CurrentUserStatus = TUserStatus.cusInvisible;
}
private void metroButton6_Click(object sender, EventArgs e)
{
this.Merk.CurrentUserStatus = TUserStatus.cusOffline;
}
private void checkBox1_CheckedChanged(object sender, EventArgs e)
{
if(checkBox1.Checked == true)
{
timer1.Start();
}
else
{
timer1.Stop();
}
}
private void timer1_Tick(object sender, EventArgs e)
{
this.Merk.CurrentUserStatus = TUserStatus.cusOnline;
Thread.Sleep(20);
this.Merk.CurrentUserStatus = TUserStatus.cusAway;
Thread.Sleep(20);
this.Merk.CurrentUserStatus = TUserStatus.cusDoNotDisturb;
Thread.Sleep(20);
this.Merk.CurrentUserStatus = TUserStatus.cusInvisible;
Thread.Sleep(20);
}
private void metroButton7_Click(object sender, EventArgs e)
{
foreach(User spamall in Merk.Friends)
{
Merk.SendMessage(spamall.Handle, "Haiiiii" + spamall.FullName + ",\n" + richTextBox1.Text + "\n\n(cash) Sent From Merk's Tutorial Tool! (cash)");
}
}
private void richTextBox1_TextChanged(object sender, EventArgs e)
{
}
}
}
我希望你能理解我的问题,并能帮助我解决将这 2 个功能添加到我的项目中需要做的事情
您可以这样获取您的在线好友合集:
var onlineFriends = Merk.Friends.Cast<User>().Where(u => u.OnlineStatus == TOnlineStatus.olsOnline);
在此之后,很容易将它们放入 ListBox
。
WPF 示例:
foreach (var friend in onlineFriends)
{
MyListBox.Items.Add(friend.FullName);
}
也就是说,我不确定是否值得花很多时间学习它,因为根据这篇博客post,Microsoft 不再真正支持 skype4comlib。
As communicated in this blog post, due to technology improvements we are making to the Skype experience, some features of the API will stop working with Skype for desktop. For example, delivery of chat messages using the API will cease to work.
例如,我无法再使用该库发送消息。
PS.: 我正在使用 Skype 7.17.0.106
我正在尝试获取所有在线 Skype 好友的列表,并将其放入名为 lst1
的 listbox
中。
我还试图让我的工具响应一些命令,比如如果有人向我发送 !news
,它会向他们发送我在代码中设置的文本。
这是我到目前为止尝试过的方法,我只是在玩弄代码以了解如何使用 skype4comlib
。
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using MetroFramework;
using MetroFramework.Forms;
using MetroFramework.Components;
using SKYPE4COMLib;
using System.Threading;
namespace betaskypetool
{
public partial class Form1 : MetroForm
{
#region Definitions
Skype Merk = new Skype();
private int count = 1;
#endregion
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void metroButton1_Click(object sender, EventArgs e)
{
try
{
this.Merk.Attach(5, true);
MessageBox.Show("You are now connected enjoy!", "Tutorial Skype Tool!");
}
catch (Exception)
{
MessageBox.Show("Failed To Connect?\n Be Sure Skype Is Open!", "Tutorial Skype Tool!");
}
}
private void metroButton2_Click(object sender, EventArgs e)
{
this.Merk.CurrentUserStatus = TUserStatus.cusOnline;
}
private void metroButton3_Click(object sender, EventArgs e)
{
this.Merk.CurrentUserStatus = TUserStatus.cusDoNotDisturb;
}
private void metroButton4_Click(object sender, EventArgs e)
{
this.Merk.CurrentUserStatus = TUserStatus.cusAway;
}
private void metroButton5_Click(object sender, EventArgs e)
{
this.Merk.CurrentUserStatus = TUserStatus.cusInvisible;
}
private void metroButton6_Click(object sender, EventArgs e)
{
this.Merk.CurrentUserStatus = TUserStatus.cusOffline;
}
private void checkBox1_CheckedChanged(object sender, EventArgs e)
{
if(checkBox1.Checked == true)
{
timer1.Start();
}
else
{
timer1.Stop();
}
}
private void timer1_Tick(object sender, EventArgs e)
{
this.Merk.CurrentUserStatus = TUserStatus.cusOnline;
Thread.Sleep(20);
this.Merk.CurrentUserStatus = TUserStatus.cusAway;
Thread.Sleep(20);
this.Merk.CurrentUserStatus = TUserStatus.cusDoNotDisturb;
Thread.Sleep(20);
this.Merk.CurrentUserStatus = TUserStatus.cusInvisible;
Thread.Sleep(20);
}
private void metroButton7_Click(object sender, EventArgs e)
{
foreach(User spamall in Merk.Friends)
{
Merk.SendMessage(spamall.Handle, "Haiiiii" + spamall.FullName + ",\n" + richTextBox1.Text + "\n\n(cash) Sent From Merk's Tutorial Tool! (cash)");
}
}
private void richTextBox1_TextChanged(object sender, EventArgs e)
{
}
}
}
我希望你能理解我的问题,并能帮助我解决将这 2 个功能添加到我的项目中需要做的事情
您可以这样获取您的在线好友合集:
var onlineFriends = Merk.Friends.Cast<User>().Where(u => u.OnlineStatus == TOnlineStatus.olsOnline);
在此之后,很容易将它们放入 ListBox
。
WPF 示例:
foreach (var friend in onlineFriends)
{
MyListBox.Items.Add(friend.FullName);
}
也就是说,我不确定是否值得花很多时间学习它,因为根据这篇博客post,Microsoft 不再真正支持 skype4comlib。
As communicated in this blog post, due to technology improvements we are making to the Skype experience, some features of the API will stop working with Skype for desktop. For example, delivery of chat messages using the API will cease to work.
例如,我无法再使用该库发送消息。 PS.: 我正在使用 Skype 7.17.0.106