AutoHotkey Community

It is currently May 27th, 2012, 12:04 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: WinWait // Loop question
PostPosted: January 5th, 2011, 8:31 pm 
Offline

Joined: August 19th, 2009, 3:06 pm
Posts: 13
I am automating a process that uses a LOOP.

The script runs through a few chores, entering info on a website and then tries to download information via a button that is available only if data is available; clicking on it brings up a dialog box. If a dialog box does NOT appear after a few seconds from the click, I want the script to increment the loop and begin at the top of the loop section (i.e. assume that now download is available).

For whatever reason, I simply cannot get this to work correctly...

Here is the section with the problem:

Code:
;select Download Manager
MouseClick, Left, %xDownloadMgr%, %yDownloadMgr%

WinWait, Windows Internet Explorer, 3
If ErrorLevel continue  ;goes to the next loop, skipping the below
Send, {SPACE}   

WinWait, File Download
Sleep, 0.5 * 1000
Send, {LEFT}
Sleep, 0.5 * 1000
Send, {SPACE}


The window that I am testing for is simply a dialog box that pops up titled only "Windows Internet Explorer" with the words "are you sure you want to navigate away...". Is there an alternate test I can try? Am I using the LOOP's "continue" correctly (which seems counterintuitive, since it is more like a skip than a continue)?

If I omit the 3 second timed test and the error test, then the whole thing works fine, until, of course, the situations when the dialog box does not appear.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 5th, 2011, 8:36 pm 
Offline

Joined: June 8th, 2006, 9:38 pm
Posts: 307
Quote:
Code:
If ErrorLevel continue  ;goes to the next loop, skipping the below


No it doesn't. It should be either

Code:
If ErrorLevel
  continue


or

Code:
IfEqual, ErrorLevel, 1, continue


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 5th, 2011, 8:52 pm 
Offline

Joined: August 19th, 2009, 3:06 pm
Posts: 13
Does the ErrorLevel reset itself when the next Loop rolls around? That is to say, does it only persist until the next thing which may test it (like another WinWait)?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 5th, 2011, 9:00 pm 
Offline

Joined: August 19th, 2009, 3:06 pm
Posts: 13
Okay... I just re-tested it...

The following DOES WORK while the dialog box comes up (i.e. once the box pops up, the space is sent and the loop continues on):
Code:
WinWait, Windows Internet Explorer
Send, {SPACE}


Simply using the ",3" on the WinWait breaks it. It just gets stuck waiting.... even when the dialog box appears. What gives?

Code:
WinWait, Windows Internet Explorer, 3
IfEqual, ErrorLevel, 1, continue   
Send, {SPACE}


Last edited by jg0001 on January 5th, 2011, 9:01 pm, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 5th, 2011, 9:01 pm 
Offline

Joined: June 8th, 2006, 9:38 pm
Posts: 307
ErrorLevel will "persist" until it is changed - either by another command that uses ErrorLevel, or by yourself.

Edit:
It's "WinWait [, WinTitle, WinText, Seconds, ExcludeTitle, ExcludeText]". Please check the documentation.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 5th, 2011, 9:11 pm 
Offline

Joined: August 19th, 2009, 3:06 pm
Posts: 13
Ah.. you know, I had that correct the first time, but I guess I must have had something else off. It is working now. Thank you for your quick assist.

So, does WinWait when the loop rolls through again reset the error test? If not, can I just set ErrorLevel := 0 or something?


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: BrandonHotkey, Google Feedfetcher, Yahoo [Bot] and 19 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group