3 Replies - 499 Views - Last Post: 23 July 2013 - 01:52 PM Rate Topic: -----

#1 tieugiang94  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 160
  • Joined: 07-December 11

How to check Process.Start() successfully started.

Posted 22 July 2013 - 10:13 AM

I'm making an application. It auto login to Yahoo Messager (YM).
I start by idea by using Process.Start() to start the Yahoo Messager.
Then use SendKeys() method to send username and password to YM.
The problem is I have to make an Sleep() for wait YM process successfully started
then SendKeys() to it. If not. My applcation will SendKeys() to it self.

=> The main problem I want to ask is: How to check an program started by Thread.Start() successfuly
started ?

Is This A Good Question/Topic? 1
  • +

Replies To: How to check Process.Start() successfully started.

#2 Curtis Rutland  Icon User is offline

  • (╯□)╯︵ (~ .o.)~
  • member icon


Reputation: 4577
  • View blog
  • Posts: 8,019
  • Joined: 08-June 10

Re: How to check Process.Start() successfully started.

Posted 22 July 2013 - 10:40 AM

Well, you can try using WaitForInputIdle:

var path = "notepad"; //replace with your own path
var process = Process.Start(path);
process.WaitForInputIdle();
DoSendKeys();//send keys code goes here

Was This Post Helpful? 0
  • +
  • -

#3 Sparky414  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 20-July 13

Re: How to check Process.Start() successfully started.

Posted 23 July 2013 - 10:54 AM

You can also try this to check if the proccess is started

bool existKillProcess(string name)
        {
            //get a list of all running processes on the computer
            foreach (Process proc in Process.GetProcesses())
            {

                if (proc.ProcessName.StartsWith(name))
                {
                    return true;
                }
            }
            return false;
        }

Was This Post Helpful? 0
  • +
  • -

#4 Curtis Rutland  Icon User is offline

  • (╯□)╯︵ (~ .o.)~
  • member icon


Reputation: 4577
  • View blog
  • Posts: 8,019
  • Joined: 08-June 10

Re: How to check Process.Start() successfully started.

Posted 23 July 2013 - 01:52 PM

That will work, assuming the process is not one that you could have multiple instances of. For example, I can run as many notepad.exe instances as I want, and you don't know which is yours if you just fetch a list by name, or even if any of them are yours (because you could have grabbed the list before the app started).
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1