johond Posted August 30, 2005 Share Posted August 30, 2005 Hi, im trying to write a script to configure a software. But there is a window that can or cannot popup, I know when this event can happen so I wrote something like this: if winwaitactive("example") then send("{SPACE}") othercode but it doesn't work.. ... any hint ? Link to comment Share on other sites More sharing options...
Gigglestick Posted August 30, 2005 Share Posted August 30, 2005 (edited) Change if winwaitactive("example") then to If WinWaitActive("example", "", 5) Then to wait 5 seconds, then continue. Or, check into AdLibEnable if you need to do other things while waiting for this window to appear. Edit: nunya! Edited August 30, 2005 by c0deWorm My UDFs: ExitCodes Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted August 30, 2005 Moderators Share Posted August 30, 2005 If WinExists("EXAMPLE") Then Send("{SPACE}") ; Rest of script EndIf Or If WinActive("EXAMPLE") Then Send("{SPACE}") ; Rest of script Else WinWaitActive("EXAMPLE", "", 5) If WinActive("EXAMPLE") Then Send("{SPACE}") ; Rest of script EndIf EndIf Wouldn't that work? 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...
Gigglestick Posted August 30, 2005 Share Posted August 30, 2005 (edited) If WinActive("EXAMPLE") Then Send("{SPACE}") ; Rest of script Else WinWaitActive("EXAMPLE", "", 5) If WinActive("EXAMPLE") Then Send("{SPACE}") ; Rest of script EndIf EndIfWouldn't that work?That's redundant. WinWaitActive works exactly like WinActive if they window is already active: it returns immediately. If not, it waits until the window is active or the time runs out.You don't need to test it twice, much less three times.If WinWaitActive("example", "", 5) Then Send("{SPACE}") EndIfEdit: Added code sample response. Edited August 30, 2005 by c0deWorm My UDFs: ExitCodes Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted August 30, 2005 Moderators Share Posted August 30, 2005 (edited) So your saying that: If WinWaitActive("example", "", 5) ThenIs correct the syntax?Edit: I'm talking about syntax, and I can't spell Edited August 30, 2005 by ronsrules 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...
Moderators SmOke_N Posted August 30, 2005 Moderators Share Posted August 30, 2005 You're right about testing it 3 times... And it works with the way you posted... It just never looked right doing it that way... But you learn something every day GJ. 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...
Gigglestick Posted August 30, 2005 Share Posted August 30, 2005 So your saying that: Is correct the syntax?Edit: I'm talking about syntax, and I can't spell Yes, the syntax is correct. It will return 1 if the window becomes active during the wait, or zero if the timeout occurs.Might want to use this with it if you don't know the exact title:Opt("WinTitleMatchMode", 2) My UDFs: ExitCodes Link to comment Share on other sites More sharing options...
JSThePatriot Posted August 30, 2005 Share Posted August 30, 2005 Here is a snippet of code I used recently to check for popup windows that may or may not pop up. (I generally had a time frame in which they would pop up). While 1 If WinExists("tim") Then ControlClick("tim", "", 1027) Else Sleep(500) $count += 1 EndIf If $count = 8 Then ExitLoop EndIf WEnd The above code (+=) requires the beta to work properly. JS AutoIt Links File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out. ComputerGetInfo UDF's Updated! 11-23-2006 External Links Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more) Link to comment Share on other sites More sharing options...
Gigglestick Posted August 30, 2005 Share Posted August 30, 2005 Yes, WinExists and ControlSend are my preference also, but I stuck to WinActive and Send since the poster asked it that way. Nice catch, JSThePatriot. My UDFs: ExitCodes Link to comment Share on other sites More sharing options...
Gigglestick Posted August 30, 2005 Share Posted August 30, 2005 While 1 If WinExists("tim") Then ControlClick("tim", "", 1027) Else Sleep(500) $count += 1 EndIf If $count = 8 Then ExitLoop EndIf WEndWinWait does exactly what your snippet does. Simplify that to:If WinWait("tim", "", 4) Then ControlClick("tim", "", 1027) EndIf My UDFs: ExitCodes Link to comment Share on other sites More sharing options...
JSThePatriot Posted August 30, 2005 Share Posted August 30, 2005 WinWait does exactly what your snippet does. Simplify that to:If WinWait("tim", "", 4) Then ControlClick("tim", "", 1027) EndIf<{POST_SNAPBACK}>True, except the reason I performed the operation the way I did, is to also allow (in the future) to display a progress bar.JS AutoIt Links File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out. ComputerGetInfo UDF's Updated! 11-23-2006 External Links Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more) Link to comment Share on other sites More sharing options...
Gigglestick Posted August 30, 2005 Share Posted August 30, 2005 True, except the reason I performed the operation the way I did, is to also allow (in the future) to display a progress bar.JSYeah, your code was right if you want to do something while you're waiting. My UDFs: ExitCodes 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