skype4comlib Create List of Friends - c#

I'm trying to grab a list of all of my Skype friends who are online and put it into my listbox named lst1.
I'm also trying to make my tool answer to some commands like if some one sends !news to me it messages them a text that I've set in the code.
This is what I've tried so far, I'm just playing around with the code to learn how to use 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)
{
}
}
}
I hope you understand my question and can help me out with what I need to do to add those 2 features to my project

You can get a collection of your online friends like this:
var onlineFriends = Merk.Friends.Cast<User>().Where(u => u.OnlineStatus == TOnlineStatus.olsOnline);
After this it's easy to put them in a ListBox.
WPF example:
foreach (var friend in onlineFriends)
{
MyListBox.Items.Add(friend.FullName);
}
That said, I'm not sure if it's worth to spend a lot of time learning it, because according to this blog post, Microsoft doesn't really support skype4comlib anymore.
https://support.skype.com/en/faq/FA12384/how-does-my-3rd-party-application-work-with-skype-and-how-will-changes-to-skype-impact-my-3rd-party-application
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.
For example, I'm not able to send a message using the library anymore.
PS.: I'm using Skype 7.17.0.106

Related

Problem with write serial output via Button Clicked

I'm currently trying to write Wisco protocol (similar to MODBUS ASCII) out to my digital output devices but faced a problem. If I clicked the ON or Off buttons (see the Image WinForm UI) that already have code to send protocol to my digital output it wouldn't do it.
But in another program where I use a textbox and write the protocol myself then I have to press Enter (If I don't press Enter key it will not work) before clicking send button and it works. What seems to be the problem here?
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 System.IO.Ports;
namespace WindowsFormsApp4
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void btnOpen_Click(object sender, EventArgs e)
{
try
{
serialPort1.PortName = "COM5";
serialPort1.BaudRate = 9600;
serialPort1.DataBits = 8;
serialPort1.Open();
progressBar1.Value = 100;
}
catch (Exception err)
{
MessageBox.Show(err.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void btnClose_Click(object sender, EventArgs e)
{
if (serialPort1.IsOpen)
{
serialPort1.Close();
progressBar1.Value = 0;
}
}
private void btnOn_Click(object sender, EventArgs e)
{
serialPort1.Write("#00WDO1,1");
}
private void btnOff_Click(object sender, EventArgs e)
{
serialPort1.Write("#00WDO1,0");
}
}
}
It turns out I just have to add \r\n to solve this problem.
private void btnSend_Click(object sender, EventArgs e)
{
if (serialPort1.IsOpen)
{
serialPort1.Write("#00WDO1,1");
serialPort1.Write("\r\n");
}
}
private void button2_Click(object sender, EventArgs e)
{
if (serialPort1.IsOpen)
{
serialPort1.Write("#00WDO1,0");
serialPort1.Write("\r\n");
}
}

Why is System.Speech.Recognition not detecting or inserting into textbox?

On visual studio code; I'm trying to get a text box to be used as a speech to text. However, when I enable it no error get thrown, nor does any speech appear. So, not entirely sure were I went wrong here. Very new to C# and visual studio. Any help is appreciated!! :) My mic is set to the default device and is able to detect me speaking. Other function such as copy to clipboard and clear work.
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 System.Speech;
using System.Speech.Recognition;
using System.Threading;
namespace MercyProto
{
public partial class Form1 : Form
{
public Grammar grammar;
public Thread RecThread;
public Boolean RecognizerState = true;
public SpeechRecognitionEngine recognizer;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
GrammarBuilder build = new GrammarBuilder();
build.AppendDictation();
grammar = new Grammar(build);
recognizer = new SpeechRecognitionEngine();
recognizer.LoadGrammar(grammar);
recognizer.SetInputToDefaultAudioDevice();
recognizer.SpeechRecognized += new EventHandler<SpeechRecognizedEventArgs>
(recognizer_SpeechRecognized);
RecognizerState = true;
RecThread = new Thread(new ThreadStart(RecThreadFunction));
RecThread.Start();
}
public void recognizer_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
{
//Recognizer recognizes the speech
if (!RecognizerState)
return;
this.Invoke((MethodInvoker)delegate
{
textBox1.Text += (" " + e.Result.Text.ToLower());
//This will add a space between each word you say
});
}
public void RecThreadFunction()
{
while (true)
{
try
{
recognizer.Recognize();
}
catch
{
//Handles errors
//Won't hear you, nothing will happen
}
}
private void button21_Click(object sender, EventArgs e)
{
RecognizerState = true;
}
private void button22_Click(object sender, EventArgs e)
{
RecognizerState = false;
}
private void button23_Click(object sender, EventArgs e)
{
Clipboard.SetText(textBox1.Text);
}
private void button24_Click(object sender, EventArgs e)
{
textBox1.Text = String.Empty;
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
}

I Want To Make A Automated Key Presser For A Game

hi i want to make a program that presses ctrl + v every 130 secs but it didnt worked for games (it worked for google, notepad etc.) i tried this code down below before
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;
namespace TradeChatBot
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void start_Click(object sender, EventArgs e)
{
timer1.Start();
}
private void stop_Click(object sender, EventArgs e)
{
timer1.Stop();
}
private void timer1_Tick(object sender, EventArgs e)
{
SendKeys.Send("^{v}");
SendKeys.Send("{ENTER}");
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
}
}
}
You can look into Clipboard class. https://msdn.microsoft.com/en-Us/library/system.windows.forms.clipboard(v=vs.110).aspx
private void Form1_Load(object sender, EventArgs e)
{
textBox1.Text= "SendKeys.Send(^{v}); ";
Clipboard.SetText(textBox1.Text);
}
private void button1_Click(object sender, EventArgs e)
{
textBox2.Focus();
SendKeys.Send("^{v}");
SendKeys.Send("{ENTER}");
}

Webbrowser control doenst show sites correctly

I'm creating a custom internet browser in c# using the webbrowser control.
And it works i can load sites and browse around and all that.
But with some sites (with alot of pictures and such) he wont put everything in the right spot so i will get text blocks inside images and vice versa.
How do i solve this ?
My code :
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication13
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
WB1.Navigate("http://nos.nl");
}
private void GoBtn_Click(object sender, EventArgs e)
{
if (AddRsBsr.Text.StartsWith("http://"))
{
WB1.Navigate(AddRsBsr.Text);
}
else if (AddRsBsr.Text.StartsWith("https://"))
{
WB1.Navigate(AddRsBsr.Text);
}
else
{
WB1.Navigate("http://www.googl.com/search?q=" + AddRsBsr.Text);
}
}
private void AddRsBsr_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Return)
{
if (AddRsBsr.Text.StartsWith("http://"))
{
WB1.Navigate(AddRsBsr.Text);
}
else if (AddRsBsr.Text.StartsWith("https://"))
{
WB1.Navigate(AddRsBsr.Text);
}
else
{
WB1.Navigate("http://www.googl.com/search?q=" + AddRsBsr.Text);
}
}
}
private void BackBtn_Click(object sender, EventArgs e)
{
WB1.GoBack();
}
private void StopBtn_Click(object sender, EventArgs e)
{
WB1.Stop();
}
private void HomeBtn_Click(object sender, EventArgs e)
{
WB1.Navigate("http://google.nl");
}
}
}
Now i know my code isn't clean and all but im doing that right now while waiting and hoping for an answer.
Thanks !
The WebBrowser component defaults to rendering in ... IE7 mode.
To have it behave as IE10/11 you need to make the registry changed described here (FEATURE_BROWSER_EMULATION): http://msdn.microsoft.com/en-us/library/ie/ee330730(v=vs.85).aspx

Is a 'method' which is not valid in the given context error

This is an example form the "Head First CSharp - page 113"
I'm getting the following error
Error 1 'Guys.Form1.joesCashLabel(object, System.EventArgs)' is a 'method', which is not valid in the given context c:\temp\Guys\Guys\Form1.cs 20 12 Guys
And the same with the other two labels
This is the code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Guys
{
public partial class Form1 : Form
{
Guy Joe;
Guy Bob;
int Bank = 100;
public void UpdateForm()
{
joesCashLabel.Text = Joe.Name + "$" + Joe.Money;
bobsCashLabel.Text = Bob.Name + "$" + Bob.Money;
bankCashLabel.Text = "Bank has" + Bank;
}
public Form1()
{
InitializeComponent();
Guy Bob = new Guy();
Bob.Name = "Bob";
Bob.Money =100;
Guy Joe = new Guy();
Joe.Name = "Joe";
Joe.Money =50;
UpdateForm();
}
private void joesCashLabel(object sender, EventArgs e)
{
}
private void bobsCashLabel(object sender, EventArgs e)
{
}
private void bankCashLabel(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
if (Bank >= 10)
{
Bank -= Joe.ReceiveMoney(10);
UpdateForm();
}
else
{
MessageBox.Show("No money in the bank");
}
}
private void button2_Click(object sender, EventArgs e)
{
Bank = Bank + Bob.GiveMoney(5);
UpdateForm();
}
}
}
it's a method(an event at that),
private void joesCashLabel(object sender, EventArgs e)
{
}
but you're using it as a variable
joesCashLabel.Text = Joe.Name + "$" + Joe.Money;
My guess, is that there's some sort of label that that event is supposed to be associated with.
You can't define two types in same project with same name, here you have three controls and three events with same name. so remove the below methods to compile without errors.
private void joesCashLabel(object sender, EventArgs e){}
private void bobsCashLabel(object sender, EventArgs e){}
private void bankCashLabel(object sender, EventArgs e){}
If you want to add events make sure you are following naming standard like ControlName_EventName

Categories

Resources