Help - Search - Members - Calendar
Full Version: Skype COM API and Skype Contact List ActiveX BETA
Skype Community > English > Development, Betas and Skype Garage > Skype Public API
Peter Kalmström
If you are developing for Windows you might be interested in this post:
http://share.skype.com/sites/devzone/2006/...ype_contac.html
jbond
I've just started using this with Delphi to write a simple bot. I'm hitting what looks like a very simple problem.

I pick up the OnMessageStatus event. This returns a pMessage: IChatMessage. pMessage.FromHandle and pMessage.ChatName are returned OK.

I want to respond to this by sending a message to the chat so I used
TSkype.SendMessage(handle, text); which seems to correspond with the CHATMESSAGE <chat_id> <message> command.

Now if the message comes from the other party I can do
TSkype.SendMessage(pmessage.FromHandle, text); and it all works. But if the message came from me, then it fails because I can't send to myself.
If I try TSkype.SendMessage(pmessage.ChatName, text); it always fails with Invalid Handle.

So how do I post from code to a specified chat? Or alternatively how do I get the handle of the chat to use in the CHATMESSAGE command (and hence the TSkype.SendMessage)?
andreskaasik_
You might try the following:

oSkype.Chat(oMessage.ChatName).SendMessage("YourText")

I hope that helps.
jbond
Yes, that worked. Thanks a lot.
kmadhu74_
I wanted to check to see if Skype running using IClient::IsRunning() API? Is it the right way to do?

When i call this function which takes VARIANT_BOOL it returns me 0x000 if skype is running or not.

What is corrrect way to query if Skype is running using Skype COM API?

Thanks
Madhu
jbond
I'm finding the ActiveX quite easy to use. There are a few inconsistencies but otherwise OK. eg Skype1.CurrentUser.MoodText is read only but Skype1.CurrentUserProfile.MoodText is read-write.

But I'm having a problem sending a command. Skype1.SendCommand(const pCommand: ICommand); My Delphi knowledge is too slim. How do I create pCommand and set pCommand.Command? It would be a lot easier to have a procedure, something like Skype1.SendCommand(const command: string, id: integer);

Anyone with the Delphi skills who can explain?
andreskaasik_
Some comments about the MoodText:

1. Skype.CurrentUser.MoodText is read only because the CurrentUser property returns the standard User object, which is also used to return information about other Skype users.

2. Skype.CurrentUserProfile returns the Profile object instead, and this can be used to modify current user properties (like from "My Profile" dialog).

The following vbscript example illustrates the sendcommand usage:

CODE


'// Create skype object

Set oSkype = WScript.CreateObject("Skype4COM.Skype","Skype_")



'// Start minimized and without splash screen

If Not oSkype.Client.IsRunning Then oSkype.Client.Start True, True End If



'// Attach

oSkype.Attach



'// Non-blocking commands

oSkype.SendCommand(oSkype.Command(0, "FOCUS"))

oSkype.SendCommand(oSkype.Command(1, "GET AUDIO_IN", "AUDIO_IN"))

oSkype.SendCommand(oSkype.Command(2, "GET AUDIO_OUT", "AUDIO_OUT"))

WScript.Sleep(1000)



'// Blocking commands

oSkype.SendCommand(oSkype.Command(3, "GET CURRENTUSERHANDLE", "CURRENTUSERHANDLE", True))

oSkype.SendCommand(oSkype.Command(4, "GET USER echo123 FULLNAME", "USER echo123 FULLNAME", True))

oSkype.SendCommand(oSkype.Command(5, "GET USER echo123 DISPLAYNAME", "USER echo123 DISPLAYNAME", True))

oSkype.SendCommand(oSkype.Command(6, "GET USER echo123 COUNTRY", "USER echo123 COUNTRY", True))

WScript.Sleep(1000)



'//Blocking search

Set oBlockingSearch = oSkype.Command(8888, "SEARCH USERS echo123", "USERS ", True)

oSkype.SendCommand(oBlockingSearch)

WScript.Echo "Search Result:" & oBlockingSearch.Reply



'//Non-blocking search

Set oSearchCommand = oSkype.Command(9999, "SEARCH USERS john doe", "USERS ")

oSkype.SendCommand(oSearchCommand)



WScript.Echo "Sleeping ..."

WScript.Sleep(30000)



'// Attachment status

Public Sub Skype_AttachmentStatus(ByVal aStatus)

 WScript.Echo ">Attachment status " & oSkype.Convert.AttachmentStatusToText(aStatus)

 If aStatus = oSkype.Convert.TextToAttachmentStatus("AVAILABLE") Then oSkype.Attach() End If

End Sub



'// Command events

Public Sub Skype_Command(ByRef aCmd)    

 WScript.Echo "C(" & aCmd.Id & "): " & aCmd.Command

End Sub



'// Reply events

Public Sub Skype_Reply(ByRef aCmd)  

 WScript.Echo "R(" & aCmd.Id & "): " & aCmd.Reply

 If IsObject(oSearchCommand) Then

   If oSearchCommand.Id = aCmd.Id Then

     WScript.Echo "Search Finished!"

   End If

 End If

End Sub

jbond
Got it. In Delphi

Skype1.SendCommand(Skype1.Command[0,'FOCUS','',false,0]);

Delphi seems to want all parameters, but this seems to work.

Thanks.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.