How do I guarantee that programmatically invoking Skype always attempts a specified command?

Robert Gustafson 606 Reputation points
2023-08-11T01:11:00.3333333+00:00

WHAT I HAVE:

Visual Basic 2019, WinForms, .NET Framework 4.0+, Skype For Desktop

MY ISSUE:

I'm writing a desktop VB.NET app that programmatically invokes Skype For Desktop with a command to start a call, chat, or other action. A simple Process.Start works fine if Skype is already loaded and running. However, if it's being invoked "cold"--i.e., it's being run for the very first time in a session or after having been exited (say, using "Quit Skype" or setting Skype to "exit on close" and closing its window)--then the initial invocation merely loads and runs it (any specified action is ignored!); it's necessary to wait a few seconds and then invoke it again with the specified action arguments if one wants it to take action. The following ssample code represents my best "play it safe" strategy:

	Private Sub DoSkype(ByVal SkypeName As String) 
	Dim Process As Process = New Process()
 	With Process.StartInfo
 		.FileName = SkypeForDesktopFolder & "\Skype.exe"
 		.Arguments = ""
		Process.Start() : Process.WaitForInputIdle()
 		Thread.Sleep(7000) '7-second delay
 		.Arguments = "skype:" & SkypeName & "?call&video=true"
 		Process.Start() 
	End With
 	End Sub 

Note that just because Skype has entered an idle state doesn't mean it's ready to carry out a command; hence the 7-second delay. However, I've got a feeling that a fixed-time delay may be too short or longer than needed depending on the user's CPU and hard drive speed, whether or not the user's already logged into Skype, and whether or not Skype's already running. Is there a more reliable way to determine when Skype is ready for the secondary Start invocation?

Please give any answers ASAP in VB.NET and as simply as possible.

Windows Forms
Windows Forms
A set of .NET Framework managed libraries for developing graphical user interfaces.
1,927 questions
VB
VB
An object-oriented programming language developed by Microsoft that is implemented on the .NET Framework. Previously known as Visual Basic .NET.
2,828 questions
0 comments No comments
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.