You are on page 1of 63

AppleScript for Absolute Starters

Bert Altenburg

_____________________________________________________________________2
_____________________________________________________________________3
0 _______________________________________________________5
1 ________________________________________________6
2 _______________________________________________10
3 I _________________________________________________13
4 __________________________________________________________15
5 __________________________________________________________17
6 list ________________________________________________________20
7 record _____________________________________________________27
8 II ________________________________________________32
9 _____________________________________________34
10 _________________________________________________________36
11 _________________________________________________________44
12 __________________________________________46
13 _____________________________________________________________51
14 handler_______________________________________________57
15 _________________________________________________________62
________________________________________________________________63

AppleScript
AppleScript


AppleScript

AppleScriptAppleScript
PhotoshopQuarkExpresInDesignFilemaker ProAppleScript
MacMac-based kiosk
k-BuilderMac
GraphiConverterBBEditWordAppleScript

AppleScript
AppleScript
15
Mac
0Mac
AppleScriptAppleScript
AppleScriptMac
AppleScriptAppleScript
MacMac OS XAppleScript

AppleScript
AppleScript
Mac OS XAppleScript
AppleScriptJava
AppleScript
10

AppleScript for Absolute Starters (Simple-Chinese Language Edition)

AppleScript

AppleScript Studio

Javascript

4
4.3
AppleScript
Script Editor2

0
Mac
Mac

1MacMac
Mac AppleScriptAppleScript

2PCMacT
Activity Monitor
Mac
distributed computing projectsDC
Folding@homeSETI@homeMac
DCDC client DCDC client
DCDC client
MacDC
Mac
MacDC
DC

http://distributedcomputing.info/projects.html

3Mac

bug

www.macinstruct.com/tutorials/crash/index.html
4Mac

53Mac
4
DCDC clientAppleScript

AppleScript for Absolute Starters (Simple-Chinese Language Edition)

1
AppleScriptMac
1Mac

Mac

beep
2

12AppleScript
1
PCAppleScriptMac
3

FredTrinoidsCellosZarvox
4Victoria

#AppleScript
VictoriaZarvox#
AppleScript
14AppleScript
AppleScript
Mac
Mac OS XAppleScript

MacFinder Finder

Mac
AppleScript



PhotoshopPhotoshop
Finder
Mac
5

5.1tellMac OS XAppleScript
FinderMac OS XAppleScript
5.3end tell5AppleScriptFinder
Finder

tellxyzAppleScript

5.1
Finder66.26.3Finder
FinderFindertell

Finder
FinderFinder

AppleScript for Absolute Starters (Simple-Chinese Language Edition)

FinderMac OS XAppleScript
7

Finder7.27.37.5beepAppleScript
beepMac OS XAppleScript
tell8

FinderbeepMac OS XAppleScript
tellFinder
beeptellFinder
Mac OS XAppleScript
tell9
9.5

Mac OS XAppleScript
9.29.3
9.5
10

Mac OS XAppleScript10.4
Finder10.5

AppleScript for Absolute Starters (Simple-Chinese Language Edition)

10

Mac

Script Editor
AppleScript

Check SyntaxAppleScript
Yo Finder! Dump my garbage.Hey Finder, clean out the bin.
FinderFinder
check syntaxcompileMac OS XAppleScript

AppleScript

11

2Mac OS XAppleScript

Run
#EnterEnter
ReturnShiftReturn

Check SyntaxRun

CommandRRun#

AppleScript for Absolute Starters (Simple-Chinese Language Edition)

12

compiled script
Run

application
Mac

FileOpen

#Run-only
Run-only#

13

3 I
1

AppleScript
tellapplication

appapplication
pqr
AppleScriptMac
AppleScriptpqr
tell
ctrl
1ctrl
Tell BlocksTellFinder
2empty the trash
tell1
tell

AppleScript for Absolute Starters (Simple-Chinese Language Edition)

14

15

26
3*4
xy variables

26x
y=3*4
AppleScript
1AppleScript
set

AppleScript
errorbug
x
pictureWidth2

AppleScript28
#
AppleScriptsetsaybeep
AppleScriptpictureWidth

_#
AppleScript
3

AppleScript for Absolute Starters (Simple-Chinese Language Edition)

16

^4

4
ResultResult
4.110.04
1000.0cubeEdgeLength^3

intergersfractional numbers1.11.2
13
real numbersreals

17

greeting1.3

AppleScript

display dialog
2

AppleScript
MacAppleScript
AppleScript
6

AppleScript for Absolute Starters (Simple-Chinese Language Edition)

18

66.2stringToBeDisplayed
6.3Hi there!
6.3stringToBeDisplayed6.2
stringToBeDisplayed

AppleScriptMac

30

&7

7.3

&resultingString

7.3is
s

AppleScriptescaping\
AppleScript9

19

blah blah \ blah


AppleScript
AppleScript

10

10\
\n
\t#
11
3

11AppleScript
15fifteen
coercion12

12.2coercedToString

12.115

AppleScript for Absolute Starters (Simple-Chinese Language Edition)

20

6 list

1display dialog

1Cancel
OK

Cancel
Canceldisplay dialog
listOK2.2

Cancel

2.2OKOK
AppleScript

2.2OK
3

34display dialog

21

AppleScriptdisplay dialog
13
4.2

2.2,4.2
Mac

6
default button33

&

7.44

AppleScript for Absolute Starters (Simple-Chinese Language Edition)

22

7.17.2addToBeginaddToEnd

12
8

8.3getmyList8
{ winter,spring}
8.298.2

9.1AppleScript
tenthitem 119.2
11th itemlast item10

AppleScript-1
-221110

12

23

r u you arethru12.2through
13.2

1312

14reverse

15

16

55

17

AppleScript for Absolute Starters (Simple-Chinese Language Edition)

24

& &

theResult18.3
myListmyList
13myListmyString

20

20.3bmyStringbmyString
20.3theResult

25

21

AppleScripts text item delimiters

2222.3
22.5

22.4text itemitem
text itemtext itemtext item
23

24

AppleScript for Absolute Starters (Simple-Chinese Language Edition)

26

2224

Mac OS XAppleScript

27

7 record
display dialoglist

display dialog
1.2

record

button returned
Yes

button returned3.3

3.3tempVarbutton pressedtheButtonPressed

AppleScript for Absolute Starters (Simple-Chinese Language Edition)

28

AppleScript

text returned5.2

text returned
30textEntered3030
AppleScript6.3
6.27.1

29

30thirty
30 yearsAppleScript
10

age

35button returnedtext returned


AppleScript

propertyitem10
AppleScript

AppleScript for Absolute Starters (Simple-Chinese Language Edition)

30

11

12

age:51213

13
14

1430
15

31

15age:73set
copy16

AppleScript for Absolute Starters (Simple-Chinese Language Edition)

32

8 II

ctrl
Dialogs

Btnbutton
Actions10

toctrlText Input - 2 Btns


7

1
Mac

33

AppleScript for Absolute Starters (Simple-Chinese Language Edition)

34

9
AppleScript

AppleScript

--

(* *)

outcomment
(*

*)

ctrlComment Tags

Comment Tags

Info

35

AppleScript for Absolute Starters (Simple-Chinese Language Edition)

36

10
1
Run

AppleScript1falsenot
true30 30true
AppleScriptifthen
2ifthenconditional statement
end if

2.1true
2.2

3.3ageEntered is myAge

37

ifthenend if
4

tellifthenend
end ifAppleScript4
4.7
5ifthenelse

5.35.6

5.3

is (or, is equal to)

>

is greater than

<

is greater than

>= is greater than or equal to

<= is less than or equal to

>= AppleScript

AppleScript for Absolute Starters (Simple-Chinese Language Edition)

38

<=AppleScript

is not greater than/=


is not
77

ifthen8

Yes8.5

AppleScript94
ifthenend if

begins with (or, starts with)

ends with

is equal to

comes before

comes after

is in

39

contains

does not start with

does not contain

is not in

doesntdoes not
does not begin withdoes not start with
comes beforecomes after10

AppleScript
11

white space
12ignoring white space
end ignoringend considering

AppleScript

AppleScript for Absolute Starters (Simple-Chinese Language Edition)

40

begins with

ends with

is equal to

is in

contains

8ifthen

end if
DialogActions

41

33
14.1

15.18.2
display dialog
resultif
elseelse ififend if
14.5

is equal to =
contains

15.1
AppleScript

AppleScript for Absolute Starters (Simple-Chinese Language Edition)

42

settostring
4

16

Boolean
+-
andornot

notnot truefalsenot falsetrue

18andxyz

orxyz

20

20.4and

43

20.5or
20.420.5

AppleScript for Absolute Starters (Simple-Chinese Language Edition)

44

11
AppleScript

1AppleScript
1.31.3 1.2

tryend try2

2.6AppleScript
end try2.4
73

45

13
tryend try
17

on error
number17.3

AppleScript for Absolute Starters (Simple-Chinese Language Edition)

46

12
column
viewFinder

path
1

1Documents

Documents

Finder2

2ikAppleScript

47

DocumentsAppleWorksreport3

3.2open filefolder
.cwkAppleWorks
ClarisWorks
Mac OS Xcommand-i

FinderFinderFinder
Preferences

Always show file extensions

AppleScript for Absolute Starters (Simple-Chinese Language Edition)

48

report.cwk4

Finder
Finder5a reference to

file 6

49

report.cwk

alias fileAppleScript
Finder
Documentsreport.cwk
report.cwkfunny_story.cwk
Macintosh HD:users:Documents:report.cwk
report.cwk IDFinder
IDreport.cwkID
FinderFinder
ID
ID
7

7Documents
alias
ID
FinderID
7

IDaliasID
report.cwk
DocumentsMiscellaneous

AppleScript for Absolute Starters (Simple-Chinese Language Edition)

50

ik

ID

alias
alias
Mac
ID
77Findertell
IDFinderFinder
Mac OS XAppleScript
AppleScriptIDFinder
3tellFinder
jpegPhotoshop

51

13

AppleScript
1repeat
2.7

telltryifthenend repeat
2

323
text returned

AppleScript for Absolute Starters (Simple-Chinese Language Edition)

52

3.21else
Mac4
5repeat

43
correctEntrytrue
6

53

set correctEntry to true


try

AppleScript for Absolute Starters (Simple-Chinese Language Edition)

54


correctEntrytrue
36

6valueEntered
710006

6
6
1
45repeat


45repeat12

8.1repeatcounterrepeat

155
9.1stepsize110.2

55

repeat11

AppleScript12
repeat

AppleScript for Absolute Starters (Simple-Chinese Language Edition)

56

57

14 handler
AppleScript
AppleScript
handler
AppleScript

3.1textToDisplay
3.43.5
3

AppleScript for Absolute Starters (Simple-Chinese Language Edition)

58

4.54.1

circleArea( )pi * 3 ^ 2get


return
66.3

6.26.3

7.1

59

7.7

8.4

x9.1x
4x

AppleScript for Absolute Starters (Simple-Chinese Language Edition)

60

10

x5
9.110.1x

AppleScript
load script
1
2load script

tell

tell
tell11

61

12.7

13

AppleScript for Absolute Starters (Simple-Chinese Language Edition)

62

15
AppleScript

Macscripter
Macintosh
AppleScript0

Bert

63

Bert AltenburgXcode
Become an Xcoder

AppleScript for Absolute StartersAltenburg


Altenburg

PC

AppleScript
AppleScript

loewez65

http://www.wally.in

AppleScript for Absolute Starters (Simple-Chinese Language Edition)

You might also like