Evening All,
I have an applescript (it was an automater script that was then automagically converted to applescript) that does what it is suppose to do except for two small niggles.
I’m not a programmer at all (the last programming was C# MANY years ago!
Here is the script:
– Click the “In Tray” URL.
set uiScript to “click static text 1 of UI Element "In Tray" of group 23 of UI Element 1 of scroll area 1 of group 3 of window "OrderWork: Service Partner Work Order Listing" of application process "Safari"”
my doWithTimeout(uiScript)
– Click the text “20110403918”
set uiScript to “click static text 1 of UI Element 1 of row 2 of table 1 of UI Element 1 of scroll area 1 of group 3 of window "OrderWork: Service Partner Work Order Listing" of application process "Safari"”
my doWithTimeout(uiScript)
– Click the text " Accept"
set uiScript to “click static text 1 of group 1 of UI Element 58 of UI Element 1 of scroll area 1 of group 3 of window "OrderWork: Service Partner Work Order Detail" of application process "Safari"”
my doWithTimeout(uiScript)
– Click the " Accept" URL.
set uiScript to “click static text 1 of UI Element " Accept" of group 70 of UI Element 1 of scroll area 1 of group 3 of window "OrderWork: Work Order Accept" of application process "Safari"”
my doWithTimeout(uiScript)
– Click the text " Finish"
set uiScript to “click static text 1 of group 1 of UI Element 62 of UI Element 1 of scroll area 1 of group 3 of window "OrderWork: Work Order Accept" of application process "Safari"”
my doWithTimeout(uiScript)
– Main calling script
on doWithTimeout(uiScript)
set endDate to (current date) + 2 – 2 second timeout value
repeat
try
run script “tell application "System Events"
" & uiScript & "
end tell”
exit repeat
on error errorMessage
if ((current date) > endDate) then
error "Can not " & uiScript
end if
end try
end repeat
end doWithTimeout
As you can see it is 5 subroutines that are called by the main calling script. What I need help with is…
- If a routine faults then an error message is raised and execution stops. If I remove the following lines then it simply hangs as it doesn’t know what to do. How can I get it to continue to run after an error condition?
if ((current date) > endDate) then
error "Can not " & uiScript
end if
- How can I get the whole thing to continually loop ad infinitum?
Model: Macbookpro
AppleScript: Latest
Browser: Safari 533.21.1
Operating System: Mac OS X (10.6)