Sign in to follow this  
Followers 0
Marspidey

While Loops

7 posts in this topic

I've have put some while loops ito my script but they aren't working. I have a few of them below. All the path names are correct. Am I missing a library or is it a computer configuration problem? Any help is appreciated. Thanks.

While WinExists( "Moving...");Wait
;MsgBox(0, "Busy", "Loop");Test
WEnd

Doesn't wait for the moving window to close and moves to next step

$wait = -1
While $wait = -1
    ControlFocus("C:\_Flash Video\CompletedSource", "", "SysListView321")
    $wait = ControlListView("C:\_Flash Video\CompletedSource", "", "SysListView321", "FindItem", $shortfilename & $ext)
WEnd

Doesn't check for video file and moves to next step

Share this post


Link to post
Share on other sites



I've have put some while loops ito my script but they aren't working. I have a few of them below. All the path names are correct. Am I missing a library or is it a computer configuration problem? Any help is appreciated. Thanks.

While WinExists( "Moving...");Wait
;MsgBox(0, "Busy", "Loop");Test
WEnd

Doesn't wait for the moving window to close and moves to next step

$wait = -1
While $wait = -1
    ControlFocus("C:\_Flash Video\CompletedSource", "", "SysListView321")
    $wait = ControlListView("C:\_Flash Video\CompletedSource", "", "SysListView321", "FindItem", $shortfilename & $ext)
WEnd

Doesn't check for video file and moves to next step

Most likely problem is that there is no window with a title "Moving...", and that ControlListView finds the string and so doesn't return -1.

Since you have not included the whole of your code these are my best guesses.


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

Most likely problem is that there is no window with a title "Moving...", and that ControlListView finds the string and so doesn't return -1.

Since you have not included the whole of your code these are my best guesses.

For the moving loop the "Moving..." window does appear but the script just keeps moving along. As for the ControlListView it shouldn't find a string until the video file is added to that folder and therefore $wait should remain -1 unless I'm wrong.

Share this post


Link to post
Share on other sites

I personally would do something like this:

while 1
If NOT WinExists("Moving...") Then ExitLoop
wend

It never hurts to put in msgboxes to debug your code.

To double check what is happening when you call a function, just msgbox its return value and confirm with the help file.

Like this:

(using your code)

$wait = -1
While $wait = -1
    ControlFocus("C:\_Flash Video\CompletedSource", "", "SysListView321")
    $wait = ControlListView("C:\_Flash Video\CompletedSource", "", "SysListView321", "FindItem", $shortfilename & $ext)
    msgbox(0,"",$wait)
WEnd

Share this post


Link to post
Share on other sites

I personally would do something like this:

while 1
If NOT WinExists("Moving...") Then ExitLoop
wend

It never hurts to put in msgboxes to debug your code.

To double check what is happening when you call a function, just msgbox its return value and confirm with the help file.

Like this:

(using your code)

$wait = -1
While $wait = -1
    ControlFocus("C:\_Flash Video\CompletedSource", "", "SysListView321")
    $wait = ControlListView("C:\_Flash Video\CompletedSource", "", "SysListView321", "FindItem", $shortfilename & $ext)
    msgbox(0,"",$wait)
WEnd
Thanks for the help guys. Your suggestions got me thinkng in a new direction. It seems to be working for now but if I have another problem with the While statements I'll repost here. Thanks again.

Share this post


Link to post
Share on other sites

Ok, below is what I added to the while loop. I have this same exact process on another computer. When this script is working correctly it is suppose to check the CompletedSource folder every ten secs for the video file and then move on to the next stage without any human contact. What it does on this computer is when it hits the 5th line of the code it reads it as "0" even though the file isn't there. Am I using "FindItem" incorrectly? Or is there a better way to find a video file than the way I'm doing now?

While $wait = -1;Check for video file to be move to completed source
;MsgBox(0, "Code Status", $wait);User prompt to wait until squeeze jobs are complete ---- Here it returns "-1" and waits for user to press "Ok"
;Sleep ( 10000 );Pauses for 10 secs
    ControlFocus("C:\_Flash Video\CompletedSource", "", "SysListView321")
    $wait = ControlListView("C:\_Flash Video\CompletedSource", "", "SysListView321", "FindItem", $shortfilename & $ext);Check for completed video file
    MsgBox( 0 , "Code Status", $wait); Here it returns "0" and wait for user to press "Ok"
WEnd

Share this post


Link to post
Share on other sites

Anyone have any suggestions?

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0