This shows you the differences between two versions of the page.
Both sides previous revision Previous revision | |||
manual:Scripting [2023/10/04 04:25] peternlewis |
manual:Scripting [2023/10/04 04:27] (current) peternlewis |
||
---|---|---|---|
Line 38: | Line 38: | ||
AppleScripts, JavaScript for Automation scripts, Shell scripts, and Swift scripts, give you a powerful way of adding new facilities we have not specifically provided for, as well as controlling other applications. | AppleScripts, JavaScript for Automation scripts, Shell scripts, and Swift scripts, give you a powerful way of adding new facilities we have not specifically provided for, as well as controlling other applications. | ||
- | ===== Web Page Interactions ===== | + | ==== Web Page Interactions ==== |
The [[actions:Execute_a_JavaScript_in_Browser|Execute a JavaScript in Browser]] actions enable deep control over a web page, as well as extracting specific data from both the page contents and HTML. | The [[actions:Execute_a_JavaScript_in_Browser|Execute a JavaScript in Browser]] actions enable deep control over a web page, as well as extracting specific data from both the page contents and HTML. | ||
- | ===== Shell Scripts ===== | + | ==== Shell Scripts ==== |
Shell scripts can execute any installed scripting language, such as perl, python, ruby or whatever. Be aware that because shell scripts are executed in a non-interactive shell, typically none of the shell configuration files (like CODE{{{.login}}} or CODE{{{.profile}}}) will be executed, which may change the way the shell script behaves. | Shell scripts can execute any installed scripting language, such as perl, python, ruby or whatever. Be aware that because shell scripts are executed in a non-interactive shell, typically none of the shell configuration files (like CODE{{{.login}}} or CODE{{{.profile}}}) will be executed, which may change the way the shell script behaves. | ||
Line 52: | Line 52: | ||
Variables whose names start with "ENV‗" override regular environment variables (eg "ENV‗PATH" overrides the regular "PATH" environment variable). | Variables whose names start with "ENV‗" override regular environment variables (eg "ENV‗PATH" overrides the regular "PATH" environment variable). | ||
- | ===== AppleScript ===== | + | ==== AppleScript ==== |
AppleScripts can perform many tasks on the Mac and control many applications. | AppleScripts can perform many tasks on the Mac and control many applications. | ||
Line 68: | Line 68: | ||
</code> | </code> | ||
- | ===== JavaScript for Automation ===== | + | ==== JavaScript for Automation ==== |
JavaScript for Automation (JXA) can access Variables with: | JavaScript for Automation (JXA) can access Variables with: | ||
Line 80: | Line 80: | ||
For details on JXA, see [[:JavaScript for Automation]]. This provides an introduction to JXA and comparison with AppleScript. | For details on JXA, see [[:JavaScript for Automation]]. This provides an introduction to JXA and comparison with AppleScript. | ||
- | ===== JavaScript ===== | + | ==== JavaScript ==== |
JavaScript in web browsers can access the variable values by using the kmvar dictionary, like kmvar.Variable‗Name (spaces are converted to underscores), but they have no way to write values back to variables, except by returning a result from the script. | JavaScript in web browsers can access the variable values by using the kmvar dictionary, like kmvar.Variable‗Name (spaces are converted to underscores), but they have no way to write values back to variables, except by returning a result from the script. | ||
Line 94: | Line 94: | ||
end tell | end tell | ||
</code> | </code> | ||
- | |||
- | The CODE{{{osascript}}} tool will execute in 64-bit mode, which may be a problem if you have old versions of AppleScript extensions installed. However, you can set the command line tool that is used to execute AppleScripts as described in [[Preferences#Other_Hidden_Preferences|Other Hidden Preferences]]. | ||
See also the [[Variables]] section. | See also the [[Variables]] section. |