Jump to content

Skype API


anixon
 Share

Recommended Posts

The following code will attach to Skype 4.2.0.187 and send an SMS without any issues. However if you upgrade to Skype 5.0.0.156 the code ceases to work and stops processing the SMS on Skype error code [2] Composing.

I would really appreciate it if someone could review the VB version commented out in the Func _SendSms and its AutoIT Skype 4.2.0.187 working version.

I have spent the better part of 3 days in the Skype Forum in conversation only to be told after being instructed to go through a process of testing Skype4Com Version 33 34 and 35 that there is no issue.

;// Create a Skype4COM object:
$oSkype = ObjCreate("Skype4COM.Skype")
$oSkypeEvent = ObjEvent($oSkype, "Skype_")
$oError = ObjEvent("AutoIt.Error", "MyErrFunc")

;// Start the Skype client:
If Not $oSkype.Client.IsRunning Then
 $oSkype.Client.Start()
EndIf

;// Verify that a user is signed in and online before continuing
While 1
 If $oSkype.CurrentUserStatus = $oSkype.Convert.TextToUserStatus("ONLINE") Then
  ExitLoop
 Else
  $oSkype.ChangeUserStatus($oSkype.Convert.TextToUserStatus("ONLINE"))
 EndIf
 Sleep(1000)
WEnd

;// The AttachmentStatus event handler monitors attachment status and returns the Skypename of the user when the status is "success":
Func Skype_AttachmentStatus($aStatus)
 MsgBox(0, "", "Attachment status " & $oSkype.Convert.AttachmentStatusToText($aStatus))
 If $aStatus = $oSkype.Convert.TextToAttachmentStatus("AVAILABLE") Then
  $oSkype.Attach()
 EndIf
 If $aStatus = $oSkype.Convert.TextToAttachmentStatus("SUCCESS") Then
  MsgBox(0, "", "Current user is " & $oSkype.CurrentUserHandle)
 EndIf
EndFunc   ;==>Skype_AttachmentStatus

Func _SendSMS()
 ;//Skype VB Example
 ;String MyMobileNumber = "+16125551212";
 ;String MyMessageText = "This is a test";
 ;SmsMessage smsmessage = skype.SendSms(MyMobileNumber, MyMessageText, "");
 ;
 ;//Converted to AutoIT
 Local $MyMobileNumber = "+61401523364";
 Local $MyMessageText = "This is a test";
 $oSms = $oSkype.SendSms($MyMobileNumber, $MyMessageText, "")
EndFunc   ;==>_SendSMS
;==>_SendSMS

Func MyErrFunc()
 ;Do Nothing
EndFunc   ;==>MyErrFunc

Sleep(5000)
_Sendsms()
Exit

I am wondering if this line of VB SmsMessage smsmessage = skype.SendSms(MyMobileNumber, MyMessageText, "");

converted to AutoIT $oSms = $oSkype.SendSms($MyMobileNumber, $MyMessageText, "") is the issue.

Link to comment
Share on other sites

  • 2 weeks later...

In the Skype Forum it has been suggested that the Skype4Com + Skype 5 API issue 'cannot send SMS's' is specifically related to Vista and Windows 7 and not Windows XP. With Skype Version 4.2.0.187 the following code will send SMS's in XP Vista and Windows 7.

Can anyone Test and confirm that the code will send an SMS with Skype 5 running in Windows XP.

'Dont forget to Change the Mobile Phone Number'

;// Create a Skype4COM object:
$oSkype = ObjCreate("Skype4COM.Skype")
$oSkypeEvent = ObjEvent($oSkype, "Skype_")
$oError = ObjEvent("AutoIt.Error", "MyErrFunc")

;// Start the Skype client:
If Not $oSkype.Client.IsRunning Then
 $oSkype.Client.Start()
EndIf

;// Verify that a user is signed in and online before continuing
While 1
 If $oSkype.CurrentUserStatus = $oSkype.Convert.TextToUserStatus("ONLINE") Then
  ExitLoop
 Else
  $oSkype.ChangeUserStatus($oSkype.Convert.TextToUserStatus("ONLINE"))
 EndIf
 Sleep(1000)
WEnd

;// The AttachmentStatus event handler monitors attachment status and returns the Skypename of the user when the status is "success":
Func Skype_AttachmentStatus($aStatus)
 MsgBox(0, "", "Attachment status " & $oSkype.Convert.AttachmentStatusToText($aStatus))
 If $aStatus = $oSkype.Convert.TextToAttachmentStatus("AVAILABLE") Then
  $oSkype.Attach()
 EndIf
 If $aStatus = $oSkype.Convert.TextToAttachmentStatus("SUCCESS") Then
  MsgBox(0, "", "Current user is " & $oSkype.CurrentUserHandle)
 EndIf
EndFunc   ;==>Skype_AttachmentStatus

Func _SendSMS()
 ;//Skype VB Example
 ;String MyMobileNumber = "+16125551212";
 ;String MyMessageText = "This is a test";
 ;SmsMessage smsmessage = skype.SendSms(MyMobileNumber, MyMessageText, "");
 ;
 ;//Converted to AutoIT [CHANGE MyMobileNumber to a Valid Number]
 Local $MyMobileNumber = "+61nnnnnnnnnnnn";
 Local $MyMessageText = "This is a test";
 $oSms = $oSkype.SendSms($MyMobileNumber, $MyMessageText, $MyMobileNumber)
EndFunc   ;==>_SendSMS
;==>_SendSMS

Func MyErrFunc()
 ;Do Nothing
EndFunc   ;==>MyErrFunc

Sleep(5000)
_Sendsms()
Exit

Thanks for the help

Ant.. :x

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...