Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

sergiobaschi

macrumors regular
Original poster
Nov 30, 2012
199
6
Gothenburg, Sweden
I've decided to learn AppleScripting. I've done some very basic scripts, such as on start up, connect to server X and Y, open this website etc etc, but want to go deeper.

I've found this book. It's almost 6 years old, so I'm thinking there must be something newer out there?

If you have any recommendations, please let me know.

(I am not a professional developer, but know Objective-C, Java and Javascript on various levels.)

Thank you for any input.
 

ArtOfWarfare

macrumors G3
Nov 26, 2007
9,558
6,058
I'm curious - what makes you think there's more to learn? What do you want to do with it that you can't already do?

AppleScript was created with the intent of being a basic scripting language that anyone, even people who don't know any other programming languages, could pick up quickly.

Further, I think Apple has pretty much abandoned it. Automator has kind of replaced it.

Just reading a book doesn't teach you languages - using a language teaches you it. I'd suggest coming up with something you'd like to do then, if you can't do it on your own, asking.
 

sergiobaschi

macrumors regular
Original poster
Nov 30, 2012
199
6
Gothenburg, Sweden
Naturally I can just stop by here and ask every time I encounter a problem. (That's how I've learned Javascript and HTML.) But at this moment, I think it's more time efficient to get deeper knowledge by doing some studying.

Basically: when I learned Javascript, I learned that document.write('hello');
wrote "hello". But I didn't know why I had to write out "document". Things like that.

What I would like to be able to do:
I want to be able to add more logic to the programming. I want to learn about if:s and loops and how to use arrays and how to store information, temporary and over time.

More practical examples of what I would like to be able to do:
I don't want to connect to the server if I'm using wifi, or if I'm already connected to the server.
I don't want to open a specific web page if the web page's already open. I don't want to open a web page at all, if I don't have any internet connection.

Also I want to use AppleScript in Indesign, to create some time saving scripts. At work we're dealing with magazines in over 50 languages, and to be able to automate some of the Indesign translation work would save us hours each month.
 

Red Menace

macrumors 6502a
May 29, 2011
578
226
Colorado, USA
There is always the AppleScript Language Guide - a PDF can be downloaded for local reference and the document contents are also available in Xcode if you have that installed.

AppleScript is still a long ways from being abandoned - AppleScriptObjC/Cocoa-AppleScript is continually being improved, and script libraries were added in Mavericks.
 

bumper314

macrumors member
Jun 23, 2009
39
0
I love AppleScript. It's a quirky little language, but immensely powerful when you start leveraging other applications to do work (process images, text, etc).

I learned AppleScript from the O'Reilly book, but it's been so long I can't remember if it was any good. However, all the content is still relevant as the language hasn't changed much in 20 years(citation needed).

If you really get into AppleScript, I totally recommend Script Debugger. I still use Version 4.5, so I can't comment on the new version 5.

I also recommend FastScripts for binding shortcuts to AppleScripts or just seeing a contextual list of scripts based on the active application. For example, I have Safari AppleScripts to download all my banks statements, convert the current URL to Markdown and put it in the clipboard, etc. You can do some fun stuff with Safari via AppleScript's "do JavaScript" function.
 

Mark FX

macrumors regular
Nov 18, 2011
159
17
West Sussex, UK
As Red Menace has eluded to, the latest trend is to learn the ApplescriptObjC language, which can be written using the Applescript Editor, or from the project template that comes with Xcode, where you can build full UI projects with Inteface Builder, and access any Cocoa Framework that is based on the Objective-C language, as well as being able to use traditional vanilla Applescript in combination.
Unfortunatley Apple have been a bit slow with coming up with any comprehensive documentation on the ApplescriptObjC language, but there are two very good books written by Shane Stanley, which represent the only detailed info on this latest and more powerful version of Applescript.

http://www.macosxautomation.com/applescript/apps/everyday_book.html
http://www.macosxautomation.com/applescript/apps/book.html

As for Apple abadoning Applescript, that's very much not the case, but they are trying to change the direction of the Applescript language, encouraging people to use Automator for automation tasks, and to use ApplescriptObjC to build the more traditional utility type applications.

Hope you find this information useful.

Regards Mark
 

sergiobaschi

macrumors regular
Original poster
Nov 30, 2012
199
6
Gothenburg, Sweden
As Red Menace has eluded to, the latest trend is to learn the ApplescriptObjC language, which can be written using the Applescript Editor, or from the project template that comes with Xcode, where you can build full UI projects with Inteface Builder, and access any Cocoa Framework that is based on the Objective-C language, as well as being able to use traditional vanilla Applescript in combination.
Unfortunatley Apple have been a bit slow with coming up with any comprehensive documentation on the ApplescriptObjC language, but there are two very good books written by Shane Stanley, which represent the only detailed info on this latest and more powerful version of Applescript.

http://www.macosxautomation.com/applescript/apps/everyday_book.html
http://www.macosxautomation.com/applescript/apps/book.html

As for Apple abadoning Applescript, that's very much not the case, but they are trying to change the direction of the Applescript language, encouraging people to use Automator for automation tasks, and to use ApplescriptObjC to build the more traditional utility type applications.

Hope you find this information useful.

Regards Mark

Thank you - this is exactly what I was looking for.

I have some knowledge in Objective-C, so I'll definitely check that out.
 

sergiobaschi

macrumors regular
Original poster
Nov 30, 2012
199
6
Gothenburg, Sweden
I love AppleScript. It's a quirky little language, but immensely powerful when you start leveraging other applications to do work (process images, text, etc).

I learned AppleScript from the O'Reilly book, but it's been so long I can't remember if it was any good. However, all the content is still relevant as the language hasn't changed much in 20 years(citation needed).

If you really get into AppleScript, I totally recommend Script Debugger. I still use Version 4.5, so I can't comment on the new version 5.

I also recommend FastScripts for binding shortcuts to AppleScripts or just seeing a contextual list of scripts based on the active application. For example, I have Safari AppleScripts to download all my banks statements, convert the current URL to Markdown and put it in the clipboard, etc. You can do some fun stuff with Safari via AppleScript's "do JavaScript" function.

I just made a script that will run every day, that logs on to my bank's website and checks how much money I have on the account connected to my VISA card. If the sum is less than 4000 SEK, then it makes a transfer of the difference. It's like an auto refill! :)
 

Mark FX

macrumors regular
Nov 18, 2011
159
17
West Sussex, UK
Yeah Applescript is awesome.

And a lot more powerful than the serious developers give it credit for, and as a serious Objective-C developer I cant help using it on a regular basis.

Let's hope Apple continue to support it, and continue to improve the ApplescriptObjC language, which will give the beginner and novice coders an introduction to programming, before they are encouraged to move on to the more powerful Objective-C language.

Regards mark
 

hhas

macrumors regular
Oct 15, 2007
126
0
Let's hope Apple continue to support it, and continue to improve the ApplescriptObjC language, which will give the beginner and novice coders an introduction to programming

Note that AppleScript-ObjC is a bridge between the AppleScript and Objective-C runtimes, not a language itself.

Also, AppleScript is a lousy language for learning to program: convoluted, buggy, obfuscated, and wildly inconsistent, riddled with 'magical' behaviors and traps for the unwary; a complete mess. The one really good reason for learning AS is if you wish to automate your desktop, as it's the only supported option which can speak Apple events correctly, so if you can wade through all the crap then it can be excellent for that. Otherwise, I'd recommend going elsewhere.[1]

--

[1] Unfortunately, finding good, popular, beginner-friendly languages to recommend is not so easy: mainstream scripting languages like Python, Ruby, and JavaScript are stupidly over-complicated, and I can't think of any modern LOGO-style languages that are particularly popular with a good spread of libraries.
 

subsonix

macrumors 68040
Feb 2, 2008
3,551
79
Also, AppleScript is a lousy language for learning to program: convoluted, buggy, obfuscated, and wildly inconsistent, riddled with 'magical' behaviors and traps for the unwary; a complete mess.

I don't think that's fair, if you use it for it's intended purpose, automation in the gui layer on OS X.
 

hhas

macrumors regular
Oct 15, 2007
126
0
I don't think that's fair, if you use it for it's intended purpose, automation in the gui layer on OS X.

Of course it's fair: the language is a mess.

While the underlying concepts are actually pretty straightforward [1], they're buried beneath a morass of well-meaning but misguided obfuscation and two decades of accummulated cruft and crud, making it far more confusing and complicated than it ever ought to be.

It just happens to be the least awful option still available to users who wish to automate their desktop apps; though as a rule of thumb, the less they try to understand it, the happier they will be.

--

[1] Simple imperative, procedural interpreted language interpreter largely comparable to JavaScript (though less dynamic), with embedded Apple events bridge that allows it to construct simple relational-style queries and dispatch remote procedure calls, and packaged as a Component Manager component. Everything is bodge and botch.
 

subsonix

macrumors 68040
Feb 2, 2008
3,551
79
Of course it's fair: the language is a mess.

While the underlying concepts are actually pretty straightforward [1], they're buried beneath a morass of well-meaning but misguided obfuscation and two decades of accummulated cruft and crud, making it far more confusing and complicated than it ever ought to be.

It just happens to be the least awful option still available to users who wish to automate their desktop apps; though as a rule of thumb, the less they try to understand it, the happier they will be.

My point is I always looked at it as a very domain specific language, for simple automation tasks, not something that is general purpose or aimed at being extensible, or building complete "Applications" with. That's why I thought the comment wasn't fair, because it didn't really take that into account. Having said all that, I don't really know much Applescript at all.
 

hhas

macrumors regular
Oct 15, 2007
126
0
My point is I always looked at it as a very domain specific language, for simple automation tasks, not something that is general purpose or aimed at being extensible

It's a general purpose language with some domain-specific extensions. None of which excuses it being a right mess in both design and implementation. Compare to something like LOGO, another general purpose end-user language with some domain-specific extensions. LOGO is the absolute model of clarity, parsimony, and accessibility: you can grasp all the language concepts in under an hour. (LOGO was designed to be easily learned by six to eight year olds, yet as a stealth Lisp is powerful and flexible enough for teaching college level Computer Science.)

Working out exactly what makes AppleScript tick requires an unholy amount of learning, guesswork, blood, sweat, and trial and error. The only guarantee is that any time you think you've truly grasped how it works, you almost certainly don't. The best way to get on with AppleScript is not to even try to understand it - you hurt yourself much less that way. :p

Having said all that, I don't really know much Applescript at all.

See the sig. :) Several hundred pages just to explain how this supposedly 'simple' language works - and even then I had to fudge, fib, or ignore a lot of the fundamental details just to avoid completely traumatizing readers.[1]

--

[1] I have a basic rule that if you can't explain something clearly and concisely, redesign it so you can. Needless to say, I develop and train my own AppleScript replacements now.:)
 

Rich.Cohen

macrumors regular
Oct 28, 2013
193
3
Washington DC
I've decided to learn AppleScripting. I've done some very basic scripts, such as on start up, connect to server X and Y, open this website etc etc, but want to go deeper.

I was in your position about 3 years ago. I bought three books and compared them. The one I liked best was Learn AppleScript, now in the third edition by Hamish Sanderson and Hanaan Rosenthal. I preferred its index to the others. I still use this book regularly.

You should also know that there is a forum devoted exclusively to AppleScript: http://macscripter.net They are very helpful and have a useful archive.

I agree with those who say that AppleScript is a quirky and sometimes difficult language. However it does work and it lends itself well to a lot of quick and dirty tasks. I suspect that there may be a memory leak problem for very long-running scripts.
 
Last edited by a moderator:
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.