Forums
New posts
Articles
Product Reviews
Policies
FAQ
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Menu
Log in
Register
Install the app
Install
Forums
macOS & iOS Developer Playground
macOS - Development and Darwin
Applescript looping and error messages
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="pcsupport" data-source="post: 1226471" data-attributes="member: 199858"><p>Evening All,</p><p> </p><p>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.</p><p> </p><p>I'm not a programmer at all (the last programming was C# MANY years ago!</p><p> </p><p>Here is the script:</p><p> </p><p>-- Click the “In Tray” URL.</p><p>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\""</p><p>my doWithTimeout(uiScript)</p><p> </p><p>-- Click the text “20110403918”</p><p>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\""</p><p>my doWithTimeout(uiScript)</p><p> </p><p>-- Click the text “ Accept”</p><p>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\""</p><p>my doWithTimeout(uiScript)</p><p> </p><p>-- Click the “ Accept” URL.</p><p>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\""</p><p>my doWithTimeout(uiScript)</p><p> </p><p>-- Click the text “ Finish”</p><p>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\""</p><p>my doWithTimeout(uiScript)</p><p> </p><p>-- Main calling script</p><p>on doWithTimeout(uiScript)</p><p> set endDate to (current date) + 2 -- 2 second timeout value</p><p> repeat</p><p> try</p><p> run script "tell application \"System Events\"</p><p>" & uiScript & "</p><p>end tell"</p><p> exit repeat</p><p> on error errorMessage</p><p> if ((current date) > endDate) then</p><p> error "Can not " & uiScript</p><p> end if</p><p> end try</p><p> end repeat</p><p>end doWithTimeout</p><p> </p><p> </p><p>As you can see it is 5 subroutines that are called by the main calling script. What I need help with is...</p><p> </p><p>1. 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?</p><p> </p><p>if ((current date) > endDate) then</p><p> error "Can not " & uiScript</p><p> end if</p><p> </p><p> </p><p>2. How can I get the whole thing to continually loop ad infinitum?</p></blockquote><p></p>
[QUOTE="pcsupport, post: 1226471, member: 199858"] 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... 1. 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 2. How can I get the whole thing to continually loop ad infinitum? [/QUOTE]
Verification
Post reply
Forums
macOS & iOS Developer Playground
macOS - Development and Darwin
Applescript looping and error messages
Top