Jump to content

Recommended Posts

The code below is used to read a column of data from a spreadsheet.

The data in the array $pinID [$i] is not always correct.

I have set SendKeyDelay from 1 to 1000 and it still happens sometimes.

Sometimes the error occurs in the first cell other times the 1000th cell.

I can run the entire script several times and after a while, no errors will occur (well no errors after 20 runs - each with 4000 cells) restarting the computer seems to give the greatest chance that the errors will happen again. After 4 to 7 errors, you will probably be error free for each subsequent run.

The difference between the "temp" variable and the "pinID" variable is usually one cell (the temp variable still had the value from the last loop) but sometimes the temp variable has a value from several loops back???

I've messed with the clipboard settings within Excel thinking that somehow they fed the temp variable the wrong info at the wrong time... nothing helped.

The errors occurs on a relatively slow (500MHz) XP system using Office 2002(XP) and on a 2GHz system running the same OS/Office. I've also tried it using Office 2003.

I've used sleep statements most everywhere to no avail.

WinWait ("Microsoft Excel", "")
WinActivate ("Microsoft Excel", "")
WinWaitActive ("Microsoft Excel", "")
Send ("^{HOME}")


For $i = 1 to $pinCNT
     WinWaitActive ("Microsoft Excel", "")
     Send ("^c")
     $temp = StringTrimRight (ClipGet (), 2)
     Send ("{ESC}")
     Send ("^c")
     $pinID [$i] = StringTrimRight (ClipGet (), 2)
     If $temp <> $pinID [$i] Then
          MsgBox (0, "AutoIt",_
          "**" & $temp & "**"  &_
          @CR & "**" & $pinID [$i] & "**"  &_
          @CR & "Clipboard error" &_
          @CR & "Start over")
          EXIT
     Endif
     Send ("{DOWN}")
Next

Any suggestions?

Thanks in advance...

[size="1"][font="Arial"].[u].[/u][/font][/size]

Link to post
Share on other sites

I've tried a single sleep 1000 statement within the loop... far fewer crashes, but still crashes... so, I tried sleep ($slp) statements every other line of the loop... where $slp was changed from 5 to 150. That slows it down to what seems stable, but testing that stability will have to wait until I have multiple systems to run it on.

Any guesses as to where "sleeps" would be most useful within the loop?

Is it faster and more stable to save the spreadsheet to text and read that in?

[size="1"][font="Arial"].[u].[/u][/font][/size]

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
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...