0

I am developing my first VB program. The program's main task is to send Skype messages using SendKeys.

I managed to send messages successfully but it is kinda slow as I need to use System.Threading.Thread.Sleep(1000) to properly send messages. If I remove the Sleep(1000) function, the program starts to do weird things like partial messages, some dialogs not showing up and at the end Skype crashed and I couldn't type anything.

Problem: How to remove Sleep(1000) to send messages without such large pause? If I have more than 500 contacts it takes lot of time.

My code:

 Dim all() As String = System.IO.File.ReadAllLines(appPath)
 Dim message_text As String = TextBox1.Text

     If all.Length > 0 Then
           For i = 0 To all.Length - 1                     
                System.Threading.Thread.Sleep(1000)   '' < ---this line
                Skype.Client.OpenMessageDialog(all(i))    
                Skype.Client.Focus()
                SendKeys.SendWait(message_text + " - " + DateTime.Now.ToString())

                SendKeys.SendWait("{ENTER}")
                System.Threading.Thread.Sleep(100)
           Next

               MessageBox.Show("Ziņa nosūtīta Skype lietotājiem")
    Else

    End If

I don't understand why it sometimes sends just partial messages as I am using SendKeys.SendWait that should wait till message text is copied in dialog and then Sending "Enter" key.

demongolem
  • 9,474
  • 36
  • 90
  • 105
Edgars
  • 913
  • 1
  • 19
  • 53
  • 1
    (Reply to comment on deleted answer) Wow, the Skype developers are harsh. I didn't know that they blocked `Skype.SendMessage` since I'm still using Skype 6.x :). But many third-party developers really want the messaging functions, so it's very stupid to remove it. – Visual Vincent Dec 04 '16 at 11:12
  • @VisualVincent , Thanks for help. Do you somehow use Skype API in your 6.x. version ? – Edgars Dec 04 '16 at 11:14
  • Yes, and it works like it used to at that time. – Visual Vincent Dec 04 '16 at 11:15
  • 1
    Here, have a link: http://www.mydoomsite.com/privateuploads/SkypeSetup_6.20.0.104.msi – Visual Vincent Dec 04 '16 at 11:18
  • @VisualVincent, You are sending messages also ? Do you have near 100% success on sending messages and receipient receives them ? I heard that even if using older Skype versions Skype API won't let to send messages because of some major changes in the way how Skype messages are sent. – Edgars Dec 04 '16 at 11:18
  • 1
    The last time I used my application was this summer, but it worked back then. I can try it when I've started my computer if you'd like. -- And yes, I send messages and they are sent properly to every target contact. The only thing you cannot send to is groups. – Visual Vincent Dec 04 '16 at 11:21
  • @VisualVincent, Thanks, I would appreciate if you could try your programm and see if it still works. – Edgars Dec 04 '16 at 11:23
  • 1
    Yep, still works like a charm! – Visual Vincent Dec 04 '16 at 11:34
  • @VisualVincent, Pleasent suprise.. One last question to be sure: You are sending to multiple contacts at the time and in contact dialog message is sent ? I mean does thaat litle message sending animation isn't visible? Thanks for great help. – Edgars Dec 04 '16 at 11:38
  • 1
    Nope, It works. I sent it to three online contacts without a problem. I asked them all to reply, so far one of them did (guessing the others are just away). But the messages are sent. – Visual Vincent Dec 04 '16 at 11:41
  • I was right, they both are labeled "Away" on Steam. – Visual Vincent Dec 04 '16 at 11:48
  • @VisualVincent, thanks. Can you,please, ask them which Skype version they are using ? I also read that message can be sent if both - Sender and Recipient have older versions. – Edgars Dec 04 '16 at 12:01
  • I don't have to ask, I already know that all three are using the latest, or one of the later versions. – Visual Vincent Dec 04 '16 at 12:04
  • @VisualVincent , I just tried to send messages to 200 Skype contacts, but just less than half received message.. Do you have ever had the same problem ? Does Skype blocks message to be sent if it is the same as previus or in specific timeframe ? – Edgars Dec 08 '16 at 14:22
  • I've never sent to _that_ many contacts, no. Are you using the API for this? It could be that you cannot send too many at one time. – Visual Vincent Dec 08 '16 at 14:29
  • @VisualVincent Yes , I am using API. Do you remember highest number of contacts that you successfully sent messages? – Edgars Dec 08 '16 at 14:33
  • No, sorry. I have tried to send to all once, but not many of them are online. I haven't really used it like you do. – Visual Vincent Dec 08 '16 at 14:41

0 Answers0