kaisimmer17
Slice-of-Life Specialist
LEVEL 1
300 XP
Introduction:
This tutorial is on how to use the Skype4ComLib Libaries in C# .NET to access our Skype program on our computer.
SKYPE4COMLib:
To use the Skype libaries you need to first obtain them via .NET Framework installation of 4.0 or later. I am using 4.5 for this tutorial, then you want to create a new Console/Form application in Visual Studio for a C# application.
Right click on your application in the 'Solution/Package Explorer', click on 'Add', then 'Reference', select 'COM' from the side tabs, and choose 'SKYPE4COMLib Libary'. Click apply & ok.
Skype Objects:
We are going to be creating an auto response in this tutorial so we need to go over a few Skype4ComLib object types;
Skype - the application used.
IUser - a Skype user.
IChatMessage - a message sent within a Skype chat conversion. Not SMS or voice calling.
Using:
Now that we are using the required libaries, we also need to 'using'/import them at the top of our file class, like so...
Skype:
First we want to create a Skype object, like so;
This will allow us to access the skype objects and functions. We also need to attach it to the currently running version of 'Skype' on the user's PC...
Missed Messages Loop:
Next we are going to write a simple infinite loop to constantly check for new messages on the user's PC. If there are any found, the application will automatically extract the required information.
To extract the username of the sender, we get their handle...
We are also going to set a message to send to the users to send the client a message...
Now we want to send the message. It takes two arguments; user handle to send the message to, and the message as a string, so we write it like so...
Thread Sleeping:
If we constantly run this loop, our CPU would burn, so we need to stop it for a few seconds every loop, we use the sleep method for this. It takes the argument for amount of time in milliseconds, so we write '2000' for 2000ms which is 2seconds...
Finished!
Full source code...
Download
This tutorial is on how to use the Skype4ComLib Libaries in C# .NET to access our Skype program on our computer.
SKYPE4COMLib:
To use the Skype libaries you need to first obtain them via .NET Framework installation of 4.0 or later. I am using 4.5 for this tutorial, then you want to create a new Console/Form application in Visual Studio for a C# application.
Right click on your application in the 'Solution/Package Explorer', click on 'Add', then 'Reference', select 'COM' from the side tabs, and choose 'SKYPE4COMLib Libary'. Click apply & ok.
Skype Objects:
We are going to be creating an auto response in this tutorial so we need to go over a few Skype4ComLib object types;
Skype - the application used.
IUser - a Skype user.
IChatMessage - a message sent within a Skype chat conversion. Not SMS or voice calling.
Using:
Now that we are using the required libaries, we also need to 'using'/import them at the top of our file class, like so...
- using
SKYPE4COMLib
;
Skype:
First we want to create a Skype object, like so;
- Skype sky =
new
Skype(
)
;
This will allow us to access the skype objects and functions. We also need to attach it to the currently running version of 'Skype' on the user's PC...
- sky.
Attach
(
)
;
Missed Messages Loop:
Next we are going to write a simple infinite loop to constantly check for new messages on the user's PC. If there are any found, the application will automatically extract the required information.
- while
(
true
)
- {
- foreach
(
IChatMessage msg in
sky.
MissedMessages
)
- {
- }
- }
To extract the username of the sender, we get their handle...
- string
handle =
msg.
Sender
.
Handle
;
We are also going to set a message to send to the users to send the client a message...
- string
message =
"This is an auto response message."
;
Now we want to send the message. It takes two arguments; user handle to send the message to, and the message as a string, so we write it like so...
- sky.
SendMessage
(
handle, message)
;
Thread Sleeping:
If we constantly run this loop, our CPU would burn, so we need to stop it for a few seconds every loop, we use the sleep method for this. It takes the argument for amount of time in milliseconds, so we write '2000' for 2000ms which is 2seconds...
- System.Threading
.
Thread
.
Sleep
(
2000
)
;
Finished!
Full source code...
- 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
SKYPE4COMLib
;
- namespace
JayPabsSkypeComLibTutorial
- {
- public
partial
class
Form1 :
Form
- {
- public
Form1(
)
- {
- InitializeComponent(
)
;
- }
- private
void
Form1_Load(
object
sender, EventArgs e)
- {
- Skype sky =
new
Skype(
)
;
- sky.
Attach
(
)
;
- while
(
true
)
- {
- foreach
(
IChatMessage msg in
sky.
MissedMessages
)
- {
- string
handle =
msg.
Sender
.
Handle
;
- string
message =
"This is an auto response message."
;
- sky.
SendMessage
(
handle, message)
;
- }
- System.Threading
.
Thread
.
Sleep
(
2000
)
;
- }
- }
- }
- }
Download
You must upgrade your account or reply in the thread to view hidden text.