This repository has been archived by the owner on Jul 24, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
applescript.html
81 lines (80 loc) · 4.89 KB
/
applescript.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<!doctype html><html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1"><meta http-equiv="X-UA-Compatible" content="ie=edge"><meta name="description" content="Applescript is a programming language used to create scripts in Mac computers."><!-- Bing --><meta name="msvalidate.01" content="45CBBE1BD8265A2217DFDA630EB8F84A" /><title>Tiny Brain Fans - Applescript</title><link rel="stylesheet" href="tinystyle.css"></head><body>
<main id="main"><article id="content"><h1 id="title">Applescript</h1><p>Applescript is a programming language used to create scripts in <a href="macos.html">Mac</a> computers.</p>
<h2>Generic Syntax</h2>
<table>
<thead>
<tr>
<th>Command</th>
<th>Effect</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>-- This is a single line comment</code><br><code># This is another single line comment</code></td>
<td>Single line comment</td>
</tr>
<tr>
<td><code>(* This is a multi line comment *)</code></td>
<td>Multi-line comment</td>
</tr>
<tr>
<td><code>open location "http://www.zombo.com"</code></td>
<td>Open URL with the appropriate program[5,6]</td>
</tr>
<tr>
<td><code>do shell script "say \"we did it\""</code></td>
<td>Run arbitrary shell script[3]</td>
</tr>
<tr>
<td><code>set variableName to value</code></td>
<td>Set a variable</td>
</tr>
<tr>
<td><code>tell application "iTerm" to ...</code></td>
<td>Tell application to do something (see below)</td>
</tr>
</tbody></table><h3>Destructure a list to new variables</h3>
<pre><code class="language-applescript">set newList to {100, 200, 300}
set { x, y, z } to newList # x=100, y=200, z=300
set a to item 2 of newList # a=200
</code></pre>
<h2>Tell Application To Do Something</h2>
<pre><code class="language-applescript">tell application "iTerm" to # put actions here
tell application "iTerm"
# put actions here
end tell
</code></pre>
<h3>Actions</h3>
<ul>
<li>
<p><code>activate</code> - Run program</p>
</li>
<li>
<p><code>open "Macintosh HD:Users:username:..."</code> - Open file at filepath[3]</p>
<ul>
<li>To open files using standard notation (<code>/Users/username/...</code>), preface the filename with <code>POSIX file</code>: <code>open POSIX File "/Users/username/..."</code></li>
</ul>
</li>
<li>
<p><code>close window 1</code> - Close window</p>
</li>
<li>
<p><code>set size of front window to {640, 400}</code> - Set window size {x, y}</p>
</li>
<li>
<p><code>set position of front window to {0, 0}</code> - Set window position {x, y}</p>
</li>
<li>
<p><code>set bounds of front window to {300, 30, 1200, 900}</code> - Set window size and position {X-start, Y-start, X-end, Y-end}; corresponds directly to pixels of display resolution</p>
</li>
</ul>
<h2>References</h2>
<ol>
<li><a href="http://downloads.techbarrack.com/books/programming/AppleScript/website/files_&_folders/opening_files.html" target="_blank">http://downloads.techbarrack.com/books/programming/AppleScript/website/files_&_folders/opening_files.html</a></li>
<li><a href="https://developer.apple.com/library/archive/documentation/AppleScript/Conceptual/AppleScriptLangGuide/reference/ASLR_error_codes.html" target="_blank">Error Messages</a></li>
<li><a href="https://stackoverflow.com/questions/10126661/applescript-how-to-open-a-file-with-the-default-program" target="_blank">https://stackoverflow.com/questions/10126661/applescript-how-to-open-a-file-with-the-default-program</a></li>
<li><a href="https://developer.apple.com/library/archive/documentation/AppleScript/Conceptual/AppleScriptLangGuide/introduction/ASLR_intro.html" target="_blank">https://developer.apple.com/library/archive/documentation/AppleScript/Conceptual/AppleScriptLangGuide/introduction/ASLR_intro.html</a></li>
<li><a href="https://developer.apple.com/library/archive/documentation/AppleScript/Conceptual/AppleScriptLangGuide/reference/ASLR_cmds.html#//apple_ref/doc/uid/TP40000983-CH216-SW54" target="_blank">https://developer.apple.com/library/archive/documentation/AppleScript/Conceptual/AppleScriptLangGuide/reference/ASLR_cmds.html#//apple_ref/doc/uid/TP40000983-CH216-SW54</a></li>
<li><a href="https://apple.stackexchange.com/questions/293777/how-do-i-open-a-generic-url-from-applescript" target="_blank">https://apple.stackexchange.com/questions/293777/how-do-i-open-a-generic-url-from-applescript</a></li>
</ol>
<p class="last-modified">Last modified: 202206101419</p></article></main><footer><nav><a href="index.html">Sitemap</a></nav><div class="social"><p>Built using <a href="http://codeberg.org/milofultz/swiki" target="_blank" rel="noopener noreferrer">{{SWIKI}}</a></p><p><a href="http://codeberg.org/milofultz/" target="_blank" rel="noopener noreferrer">Codeberg</a></p><p><a href="http://milofultz.com/" target="_blank" rel="noopener noreferrer">milofultz.com</a></p><p><a href="https://merveilles.town/@milofultz" target="_blank" rel="me noopener noreferrer">Mastodon</a></p></div></footer></body></html>