Limitations of Applescript?

Hi there,

I’m fairly new to Applescript and before I start tinkering around with a script I was wanting to check whether my goal of automating the OCR’ing of new pdfs is even feasible using Applescript. I know technically it can it be done but because each pdf will vary in length and the amount of time it takes to OCR the document will vary, maybe this is a process that shouldn’t be automated using Applescript?

I am currently experimenting with a script that will work in conjunction with Hazel. So when I have finished scanning a document using Scanner Pro on my iOS and it is synced in my Google Docs folder, a Hazel rule has Readiris (OCR software) open the document. However, Readiris requires a dialogue box to be clicked before it starts to recognise the text and then the document needs to be converted and saved (which takes varying amounts of time depending on the pdf).

I tried using the following script in Hazel:

tell application "Readiris"
	tell front document
		save as text
		delay 1
		tell application "System Events"
			keystroke return
		end tell
		save as pdf
		close saving no
	end tell
end tell

Before I iron out the bugs in the above workflow, I was wanting to know whether Applescript is suitable for automating processes that take varying amounts of time.

Thank you, in advance, for your advice.

Model: Macbook Pro early 2011
Browser: Safari 537.36
Operating System: Mac OS X (10.8)

See “with timeout” in the language guide.