titouille Posted October 18, 2005 Share Posted October 18, 2005 Hello everybody ! I discover AutoIt this day, and have tried some samples and my own tests for my need. My case : I have a Flash animation to launch. In some cases, this animation launch an external wma player via FSCommand When this player (media player classic) is launched, it take focus, so my animation lost the focus, and key pad navigation is out. So I have tried to build a script to make the following things : 1. hide trayIcon AutoIt 2. Launch Loader.exe (swf stand-alone executable) 3. Create a loop who wait and test if "Media Player Classic" is launched. if it's case, pass the focus to the Flash animation. 4. If animation is closed, test if "Media Player Classic" is launched. If it's case, close it, and 5. Close AutoIt3.exe process (shown in task manager) here is my script : #NoTrayIcon ; var to exit Dim $exit = 0 ; run main application Run("Loader.exe") ; wait for running WinWaitActive("Macromedia Flash Player 7") ; set the loop While $exit < 1 If WinWaitClose( "Macromedia Flash Player 7" ) = 1 Then MsgBox( 0, 'test', 'test 1' ) $exit = 1 EndIf winWaitActive( "Media Player Classic" ) ;WinSetOnTop( "Macromedia Flash Player 7", "", 1) WinActivate( "Macromedia Flash Player 7" ) WEnd If WinExists( "Media Player Classic" ) = 1 Then WinClose( "Media Player Classic" ) WinWaitClose( "Media Player Classic" ) MsgBox( 0, 'exit', 'exit...' ) Else MsgBox( 0, 'exit without mpc close', 'exit without mpc close;)' ) EndIf So I want to construct a loop which stop if main animation is closed. My problems are : 1. The WinActivate function plays only one time 2. If the $exit variable is set to 1, code after the loop is executed only if Media Player Classic is launched 3. The AutoIt3.exe process isn't killed after closing the animation If anyone have some suggestions about my script, or alternative solutions, I'm waiting for... Thanks in advance for any answer Thierry Link to comment Share on other sites More sharing options...
titouille Posted October 18, 2005 Author Share Posted October 18, 2005 (edited) Ok, it was a misunderstanding of the winWait*** methods... I have now understand that theses methods stop all other process and wait for an event. So I have rewrited my script and it's really simple to do it : replace main loop by this code : Dim $animationTitle = "Macromedia Flash Player 7" While $exit < 1 if WinWaitNotActive( $animationTitle ) = 1 Then if WinExists( $animationTitle ) Then WinActivate( $animationTitle ) Else $exit = 1 EndIf EndIf WEnd and all work. mplayerc.exe seems to close automatically when Flash player is closed, without pass in the final if statement. I don't know why, but this is good for me If anyone find a mistake or know an optimisation, I listen Edited October 18, 2005 by titouille Link to comment Share on other sites More sharing options...
Skruge Posted October 19, 2005 Share Posted October 19, 2005 If anyone find a mistake or know an optimisation, I listen LxP posted a good one in this thread: http://www.autoitscript.com/forum/index.php?showtopic=16788 Following that example: Dim $animationTitle = "Macromedia Flash Player 7" While WinExists($animationTitle) WinActivate($animationTitle) WinWaitNotActive($animationTitle) WEnd [font="Tahoma"]"Tougher than the toughies and smarter than the smarties"[/font] Link to comment Share on other sites More sharing options...
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