Giter Club home page Giter Club logo

learn-applescript's Introduction


/AppleScriptLogoHQ.png

Learning AppleScript (programming language)

This document will go over my knowledge of the AppleScript programming language. Since I don't have a Macintosh or a functional MacOS virtual machine yet (I currently can't do virtual machines due to memory and export issues, as of 2021 November 24th) all examples here are not tested.

I don't know very much about this language either. I know a little bit, and this knowledge was obtained from Wikipedia.

Comments in AppleScript

AppleScript has multiple types of single line comments, depending on what version of MacOS you are using.

-- This is a standard single line comment
# This is a single line comment if you use Mac OS X Leopard (10.5) or later
(* This
is a multi-line
comment *)
(* This is
* also a
* multi-line
* comment
*)

/!\ This example has not been tested yet, and may not work

Hello World in AppleScript

There are 3 different ways to write a Hello World program in AppleScript, there isn't much I can add from this example, it is from Wikipedia.

display dialog "Hello, world!" -- a modal window with "OK" and "Cancel" buttons

/!\ This example has not been tested yet, and may not work

display alert "Hello, world!" -- a modal window with a single "OK" button and an icon representing the app displaying the alert

/!\ This example has not been tested yet, and may not work

say "Hello, world!" -- an audio message using a synthesized computer voice

/!\ This example has not been tested yet, and may not work

Printing a document in AppleScript

WARNING: this is NOT to be confused with printing a document to your screen. If you are running MacOS or an AppleScript compiler, this command may use your physical paper printer to print this out.

print page 1
print document 2
print pages 1 thru 5 of document 2

/!\ This example has not been tested yet, and may not work

Telling an application to stop in AppleScript

WARNING: Make sure to save your work before running this command, as it may kill the program without a save prompt.

tell application "LibreOffice Writer"
  quit
end tell

I replaced Wikipedias example of Microsoft Word with LibreOffice Writer, as it is more respectful to user privacy and is not proprietary.

/!\ This example has not been tested yet, and may not work

Repeat loops in AppleScript

This loop will repeat indefinitely:

repeat
	display dialog "AppleScript is repeating a script..."
end repeat

/!\ This example has not been tested yet, and may not work

This loop will repeat 5 times

repeat 5 times
     display dialog "ONE STAR!!!"
end repeat

/!\ This example has not been tested yet, and may not work

Other knowledge of AppleScript

  1. AppleScript is not a semicolon and curly bracket language, instead, it uses this character: ¬

  2. AppleScript was developed by Apple Inc.

  3. AppleScript works on MacOS 7 and above

  4. AppleScript commonly uses the .applescript file extension, but it can also use the .scpt and .scptd file extensions (although I don't have them memorized, so I don't use them)

  5. AppleScript contains support for voice commands

  6. AppleScript currently is a MacOS/iOS only language

  7. AppleScript is a scripting language

  8. No other knowledge of the AppleScript programming language.


learn-applescript's People

Contributors

seanpm2001 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.