Re: applescripting the calculator
Re: applescripting the calculator
- Subject: Re: applescripting the calculator
- From: "J. Stewart" <email@hidden>
- Date: Wed, 24 Jan 2007 15:47:24 -0500
On 1/24/07 at -0500 Gordon Beckhart said this
>dear friends
>Been tring to teach my self applescript and this bit with the
>calculator has me frustrated.
>The command "exists" seems to work and returns me a "true". Trying
>to click, press the number buttons just returns an error message.
>
>this is the applescript, can anyone suggest how to make it function?
>thanks
>Gordon Beckhart
>tell application "Calculator"
>
> tell application "System Events"
>
> tell application process "calculator"
> tell window "calculator"
> exists button "9" of group 1
> --exists button "Clear" of group 1
> --click button "9" of group 1
> --press button "plus" of group 1
> --press button "5" of group 1
> --press button "equals" of group 1
> end tell
> end tell
> end tell
>end tell
Scripting the GUI as you are trying to do is or can be very frustrating. It really should be used only as a last resort when there is no other recourse.
-- script start
9 + 5
-- script end
Is an Applescript, try it in script editor. It does exactly what you tried to do with Calculator, returns 14
You would serve yourself better if you learn to use Applescript itself and forget GUI scripting until you have a firm grip on the basics of the language.
The Place to start is with Apple's outdated Applescript Language Guide, available here --
<http://developer.apple.com/documentation/AppleScript/Conceptual/AppleScriptLangGuide/index.html>.
Once you've been through that, I highly recommend Matt Neuburg's book 'AppleScript: The Definitive Guide' to move on to the next level.
<http://www.oreilly.com/catalog/applescpttdg/>
JBS
--
Do Lipton Tea employees take coffee breaks? - George Carlin
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/mailman//archives/applescript-users
This email sent to email@hidden