BoB- Posted December 29, 2005 Share Posted December 29, 2005 (edited) AutoIt Version 3.1.1 WinActive ( "title" [, "text"] ) title - The title of the window to activate. text - [optional] The text of the window to activate. Success: Returns 1. Failure: Returns 0 if window is not active. Sample Code Opt("WinTitleMatchMode", 4) Run("Explorer.exe") $CheckWindow = WinActive("classname=ExploreWClass") WinWaitActive("classname=ExploreWClass") WinActivate("classname=ExploreWClass") If $CheckWindow = 1 Then MsgBox(0, "Success", "Found Explorer window!", 15) Elseif $CheckWindow = 0 Then MsgBox(0, "Error", "Could not find Explorer window.", 15) EndIf When launching "Explorer.exe" it brings up 'My Documents' and displays the msg box that claims it couldn't find the window when it had to wait till it found the window to even continue on past the WinWaitActive which obviously found the window. So in simple words on the return 0 = success, and 1 = failure rather than the other way around. This does not only happen with Explorer.exe. Anyways just thought I'd let you guys know . Edited December 29, 2005 by BoB- Link to comment Share on other sites More sharing options...
LxP Posted December 29, 2005 Share Posted December 29, 2005 (edited) Welcome to the forums!Run("Explorer.exe") $CheckWindow = WinActive("classname=ExploreWClass")This is the problem here -- you are determining whether or not an Explorer window is active immediately after running it. There is no guarantee at this point that the window has indeed appeared on-screen; consequently this is no bug. You need to do something like this:Opt('WinTitleMatchMode', 4) Run('Explorer') WinWait('ClassName=ExploreWClass') WinActivate('ClassName=ExploreWClass') WinWaitActive('ClassName=ExploreWClass')Edit: To make my example somewhat clearer, consider a program whose window does not appear for some time after launching it (e.g. a Microsoft Office application). Script execution continues immediately after the request to start a program is passed to Windows; AutoIt will not wait for a window to appear. Edited December 29, 2005 by LxP Link to comment Share on other sites More sharing options...
jpm Posted December 29, 2005 Share Posted December 29, 2005 as it is a support question I move it to the correct forum Link to comment Share on other sites More sharing options...
BoB- Posted January 4, 2006 Author Share Posted January 4, 2006 Ahhh I feel like an idiot now . I didn't even think about it at the time that I wasn't waiting for the window to appear before checking for it. Sorry about that . Thanks a lot though. Link to comment Share on other sites More sharing options...
cappy2112 Posted January 4, 2006 Share Posted January 4, 2006 Ahhh I feel like an idiot now . I didn't even think about it at the time that I wasn't waiting for the window to appear before checking for it. Sorry about that . Thanks a lot though.Don't feel like an idiot. There are no forums here for idiots, but if there were, you wouldn't be alone ;-)The delay waiting for any window or dialogue has bitten me many times. I now have theIf Not acitve, then activate xxxWinWaitActive() stuff everywhere, as well as some Sleep() calls too Link to comment Share on other sites More sharing options...
cappy2112 Posted January 4, 2006 Share Posted January 4, 2006 as it is a support question I move it to the correct forum Is this not the v3 Support forum? Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted January 4, 2006 Moderators Share Posted January 4, 2006 Is this not the v3 Support forum?It was probably posted in another forum cappy, and jpm moved it here from there. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. 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