ManelRodero Posted September 9, 2009 Posted September 9, 2009 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!
jvanegmond Posted September 9, 2009 Posted September 9, 2009 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. github.com/jvanegmond
ManelRodero Posted September 10, 2009 Author Posted September 10, 2009 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 :-(
jvanegmond Posted September 10, 2009 Posted September 10, 2009 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! github.com/jvanegmond
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now