Jump to content

How to use WinWait and ShellExecuteWait


Recommended Posts

Hello,

I'm trying to use WinWait for enter a username/password when requested by an application that is executed using ShellExecute.

At the same time, I need to wait for the application to finish before I can continue the script, so I need to use ShellExecuteWait.

A code like this one:

...
StartEvent() ; Execute before running Windows Media Encoder

ShellExecute(@ProgramFilesDir & "\Windows Media Components\Encoder\wmenc.exe",$sWMEFileRun & " " & "/start","","open",@SW_MAXIMIZE)
WinWaitActive("Broadcast Password")
Send("{ALT}u" & $username & "{TAB}" & $password & "{TAB}{TAB}{SPACE}")

StopEvent() ; Execute after closing Windows Media Encoder
...

If I use ShellExecute, AutoIt executes the command and continues. After this, I wait for the window and enter the username/password but I'm executing StopEvent() before finishing the command executed by ShellExecute.

If I change ShellExecute by ShellExecuteWait ... AutoIt only continues after closing my program (so WinWait is not entering the username/password).

My questions is: how to handle this situation?

Thank you very much!

Link to comment
Share on other sites

Like this:

StartEvent() ; Execute before running Windows Media Encoder

ShellExecute(@ProgramFilesDir & "\Windows Media Components\Encoder\wmenc.exe",$sWMEFileRun & " " & "/start","","open",@SW_MAXIMIZE)
WinWaitActive("Broadcast Password")
Send("{ALT}u" & $username & "{TAB}" & $password & "{TAB}{TAB}{SPACE}")

ProcessWaitClose("wmenc.exe") ; this

StopEvent() ; Execute after closing Windows Media Encoder

It's probably better to rewrite it to use the Run function so you can pass the PID.

Link to comment
Share on other sites

Many thanks!

I've replaced ShellExecute by Run (for getting the PID of the process).

It works!

Sorry for not reading the manuals but I'm in the process of converting a CMD file (created and maintained for two years) to AutoIt without knowing anything about this language. I'm a newbie :-(

Link to comment
Share on other sites

You're welcome. : )

What great honesty to admit to not reading the manuals. I didn't notice you hadn't done so already, because you clearly showed you had given the problem a good deal of thought and what were the problems you struggled with (you saw a solution in some kind of multithreading environment, while that is clearly impossible). Maybe programming in AutoIt just comes very easy to you, and you don't need to read the manual for these purposes. Best of luck!

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...