Jump to content

Open Source error


lee
 Share

Recommended Posts

i am getting an error window displaying the message "Open Source error" during script execution. the line at which the error occurs is simply:

Send("Y")

the error is somewhat random -- sometimes it works, and sometimes it doesn't. i can't figure out any pattern to it. what could possibly be causing this? any way to work around it or figure out more about what the error is? all i'm trying to do is select an option from a dialog window. i've tried replacing the Send() with a MouseClick() command, but i still get the same error.

Link to comment
Share on other sites

give us your whole script

; AutoIt script to scan pages to a .txt file

dim $TRProProg, $TRWinTitle, $TRPropWinTitle, $TRSaveAsWinTitle
dim $TRAutoWinTitle, $MaxPagesToScan, $PageKntr, $TRTransferringWinTitle
dim $File, $SaveFileName
dim $False, $True

$False = 0
$True = 1

$TRProProg = "C:\TypeReader Pro 6.0\TR.exe"
$TRWinTitle = "TypeReader"
$TRAutoWinTitle = "Auto"
$TRPropWinTitle = "Properties"
$TRSaveAsWinTitle = "Save As"
$MaxPagesToScan = 5

; get name of output file
if FileExists("scan.tmp") = $False then
   MsgBox(48,"Error","Could not locate scan control file!")
   exit
endif
$File = FileOpen("scan.tmp",0)
$SaveFileName = FileReadLine($File)
FileClose($File)

FileDelete($SaveFileName)

; start typereader and wait for it to be active
Run($TRProProg)
if WinWaitActive($TRWinTitle,"",10) = $False then
   MsgBox(48,"Error","Could not start scanning program!")
   exit
endif

; start autoscan and wait for auto window
Send("{F5}")
for $PageKntr = 1 to $MaxPagesToScan
   WinWaitActive($TRAutoWintitle,"",30)
   if WinActive($TRAutoWintitle) then
      if $PageKntr = $MaxPagesToScan then
         WinWaitActive($TRAutoWinTitle)
         Send("N")
      else
         WinWaitActive($TRAutoWinTitle)
         Send("Y")
      endif
   else
      MsgBox(48,"Error","Could not determine end of page scanned!")
      exit
   endif      
next

; wait for properties window
if WinWaitActive($TRPropWinTitle,"",120) = $False then
   MsgBox(48,"Error","Could not determine end of scan!")
   exit
endif

; close properties window and do file save
Send("{ESC}")
Send("!F")
Send("A")
if WinWaitActive($TRSaveAsWinTitle,"",10) = $False then
   MsgBox(48,"Error","File save failed!")
   exit
endif
Send($SaveFileName)
Send("!S")

; end typereader
WinClose($TRWinTitle)

; deal with save changes window
if WinActive($TRWinTitle,"Save changes to") = $True then
   Send("N")
endif
Link to comment
Share on other sites

such message cannot come from AutoIt as this string is not in the source code of AutoIt.

It should be the application you are sending to. :">

<{POST_SNAPBACK}>

that actually occurred to me -- although the title of the window with the error message is the name of the AutoIt script, which made me think the error must be coming from the script. maybe that's coincidence? i guess i could change the name of the script and see if the window title of the error message stays the same -- which would probably prove that the error is indeed coming from the application itself.
Link to comment
Share on other sites

sure enough the error message is coming from the application -- i had named the script "scan" and the error window title was "scan" which made me think it was the script. but i changed the name of the script and the error window was still "scan", so the culprit is indeed the application itself.

which of course now begs the question of why an application would work correctly with physical key presses or mouse clicks, but fail when the keypress/mouse click was simulated via AutoIt.

Link to comment
Share on other sites

sure enough the error message is coming from the application -- i had named the script "scan" and the error window title was "scan" which made me think it was the script.  but i changed the name of the script and the error window was still "scan", so the culprit is indeed the application itself.

which of course now begs the question of why an application would work correctly with physical key presses or mouse clicks, but fail when the keypress/mouse click was simulated via AutoIt.

<{POST_SNAPBACK}>

maybe you could try compiling the script to an exe... then see if you recieve the same error

just an idea

8)

NEWHeader1.png

Link to comment
Share on other sites

Also, use a MsgBox to show all of your variables just before the proposed error (an ancient method of debugging). Your variables may not hold the information you are hoping for...

<{POST_SNAPBACK}>

i'm not sure what value that is -- the command that generates the error is a simple SEND("Y"). no variables involved. the script is doing exactly what it's supposed to do -- it's just that when the "Y" is sent, the application program doesn't respond as it should.
Link to comment
Share on other sites

i'm not sure what value that is -- the command that generates the error is a simple SEND("Y").  no variables involved.  the script is doing exactly what it's supposed to do -- it's just that when the "Y" is sent, the application program doesn't respond as it should.

<{POST_SNAPBACK}>

Could be from :

$TRProProg = "C:\TypeReader Pro 6.0\TR.exe"

Isn't a AutoIt error. AutoIt's error messages are like the screenshot(below).

Link to comment
Share on other sites

i am getting an error window displaying the message "Open Source error" during script execution.  the line at which the error occurs is simply:

"Open Source error", "sometimes it works, and sometimes it doesn't" ???

Maybe I'm wrong, but could it be that your scanner/OCR Software has a technical problem which occurs only sometimes? Probably the error pops up only when you use the script, because your script sends the "Y" much faster after the pop-up window than you could ever do manually.

Try to add a sleep(2000) before Send("N") and Send("Y"). Just an idea.....

WinWaitActive($TRAutoWinTitle)
         sleep(2000)
         Send("N")
      else
         WinWaitActive($TRAutoWinTitle)
         sleep(2000)
         Send("Y")

Cheers

Kurt

__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

Link to comment
Share on other sites

Could be from :

$TRProProg = "C:\TypeReader Pro 6.0\TR.exe"
no, that part works fine -- otherwise the program wouldn't even launch.

Isn't a AutoIt error. AutoIt's error messages are like the screenshot(below).

yeah, i know --see post #6 in this thread.
Link to comment
Share on other sites

"Open Source error", "sometimes it works, and sometimes it doesn't" ???

Maybe I'm wrong, but could it be that your scanner/OCR Software has a technical problem which occurs only sometimes? Probably the error pops up only when you use the script, because your script sends the "Y" much faster after the pop-up window than you could ever do manually.

Try to add a sleep(2000) before Send("N") and Send("Y"). Just an idea.....

<{POST_SNAPBACK}>

that was one of my initial thoughts -- so i scattered SLEEP's throughout the code, even threw in some disk i/o for good measure. didn't help. ;)
Link to comment
Share on other sites

thanks for all the suggestions here, but i've decided to drop back and punt on this one. the end user has been looking for an excuse to upgrade their scanner and their scanner software (which is rather ancient, which could be part of the problem) -- and so i've convinced them to go ahead and do that, rather than try to chase down what would appear to be a rather strange issue. hopefully i'll be able to automate the new software/scanner without any of these type problems....... if not, i'll be back. ;)

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...