KXM Posted December 25, 2004 Posted December 25, 2004 (edited) First, I just want to say, I did search. However searching with the word 'error' is not easy. Here's my issue, I can't program. So I have no idea what I'm doing. I'm trying to call one function if a given program load correctly, and another if it fails. Here is my code: AutoItSetOption("RunErrorsFatal", 0) AutoItSetOption("WinTitleMatchMode", 1) Dim $BTV = "C:\Program Files\SnapStream Media\Beyond TV 3\BTVD3DShell.exe /displaymode:fs" Dim $Meedio = "C:\Program Files\Meedio\Meedio Essentials\Meedio.exe -no-splash -single-instance" Main() Func Main() WinClose("Meedio Essentials", "") BTV() EndFunc Func BTV() runwait($BTV) If $BTV = 0 Then Call ("ErrorBTV") Else Call ("Meedio") EndIf EndFunc Func Meedio() run($Meedio) MsgBox(4, "worked", "worked") EndFunc Func ErrorBTV() MsgBox(4096, "Could Not Load BTV", "Loading BTV Failed, Please contack KXM on Meedio.com") Exit EndFunc Any clues as to what I'm doing wrong? TIA, KXM Edited December 25, 2004 by KXM
SlimShady Posted December 25, 2004 Posted December 25, 2004 I cleaned up your script using Tidy® and added If @error.You know why your script didn't work as expected?Because you didn't read help file very well. Specifically: the remarks part of the Run/RunWait function.By default the script will terminate with a fatal error if the Run function fails. To set @error to 1 as an indication of failure, see AutoItSetOption.AutoItSetOption("RunErrorsFatal", 0) AutoItSetOption("WinTitleMatchMode", 1) Dim $BTV = "C:\Program Files\SnapStream Media\Beyond TV 3\BTVD3DShell.exe /displaymode:fs" Dim $Meedio = "C:\Program Files\Meedio\Meedio Essentials\Meedio.exe -no-splash -single-instance" Main() Func Main() WinClose("Meedio Essentials", "") BTV() EndFunc ;==>Main Func BTV() RunWait($BTV) If @error = 1 Then Call("ErrorBTV") Else Call("Meedio") EndIf EndFunc ;==>BTV Func Meedio() Run($Meedio) MsgBox(4, "worked", "worked") EndFunc ;==>Meedio Func ErrorBTV() MsgBox(4096, "Could Not Load BTV", "Loading BTV Failed, Please contack KXM on Meedio.com") Exit EndFunc ;==>ErrorBTV
KXM Posted December 25, 2004 Author Posted December 25, 2004 (edited) First THANKS for helping so quickly! Figured no one would reply until tomorrow at best. I should have been more clear in my request, I had tried what you suggested first. However, when I did that the script does not wait for BTV to end, before calling 'Meedio', per 'RunWait'. Maybe it's a matter of another function being need, but I'm not sure how/why. Also, what is ';==>Function Name' Is this part of Tidy®? THANKS again for your help! Edited December 25, 2004 by KXM
SlimShady Posted December 25, 2004 Posted December 25, 2004 I have no idea why the above script didn't work.Because it should. Actually the following script works exactly like the above script.Yes. Tidy® is a script that cleans up AutoIt3 scripts.Available here.AutoItSetOption("RunErrorsFatal", 0) AutoItSetOption("WinTitleMatchMode", 1) Dim $BTV = '"C:\Program Files\SnapStream Media\Beyond TV 3\BTVD3DShell.exe" /displaymode:fs' Dim $Meedio = '"C:\Program Files\Meedio\Meedio Essentials\Meedio.exe" -no-splash -single-instance' Main() Func Main() WinClose("Meedio Essentials", "") BTV() EndFunc ;==>Main Func BTV() $PID_BTV = Run($BTV) If @error = 1 Then Call("ErrorBTV") Else ProcessWaitClose($PID_BTV) Call("Meedio") EndIf EndFunc ;==>BTV Func Meedio() Run($Meedio) MsgBox(4, "worked", "worked") EndFunc ;==>Meedio Func ErrorBTV() MsgBox(4096, "Could Not Load BTV", "Loading BTV Failed, Please contack KXM on Meedio.com") Exit EndFunc ;==>ErrorBTV
KXM Posted December 25, 2004 Author Posted December 25, 2004 I'm sorry, it seems to be a problem with the program it's loading. The program being loaded seems to return an error if it's background program is not running, even though it will still load fine. All I need to do is check if the backgroung program is running, if not load it, than load the other. Easy enough. Sorry for being such a newbee. THNX again. Happy Holidays.
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