This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Next revision Both sides next revision | ||
JavaScript_for_Automation [2016/04/27 09:28] peternlewis |
JavaScript_for_Automation [2016/05/09 03:28] alain JMTX template + add forum links & internal links |
||
---|---|---|---|
Line 28: | Line 28: | ||
{{:chromwinkeys.png?400|}}{{:undefined:jssafariactiondocument.png?400|}} | {{:chromwinkeys.png?400|}}{{:undefined:jssafariactiondocument.png?400|}} | ||
- | Keyboard Maestro’s [Execute a JavaScript in Safari](https://wiki.keyboardmaestro.com/action/Execute_a_JavaScript_in_Safari) and [Execute a JavaScript in Google Chrome](https://wiki.keyboardmaestro.com/action/Execute_a_JavaScript_in_Google_Chrome) actions are for interacting with web pages, the [Execute a JavaScript in Custom Prompt](https://wiki.keyboardmaestro.com/action/Execute_a_JavaScript_in_Custom_Prompt) action is for interacting with Custom HTML Prompts, whereas JXA is for automating OS X and OS X Applications via the [Execute a JavaScript For Automation](https://wiki.keyboardmaestro.com/action/Execute_a_JavaScript_For_Automation) action. | + | Keyboard Maestro’s [[action:Execute a JavaScript in Safari|Execute a JavaScript in Safari]] and [[action:Execute a JavaScript in Google Chrome|Execute a JavaScript in Google Chrome]] actions are for interacting with web pages, the [[action:Execute a JavaScript in Custom Prompt|Execute a JavaScript in Custom Prompt]] action is for interacting with Custom HTML Prompts, whereas JXA is for automating OS X and OS X Applications via the [[action:Execute a JavaScript For Automation|Execute a JavaScript For Automation]] action. |
=====The basics – AppleScript and JavaScript for Automation side by side===== | =====The basics – AppleScript and JavaScript for Automation side by side===== | ||
Line 253: | Line 254: | ||
// "Sun -> Mon -> Tue | // "Sun -> Mon -> Tue | ||
- | |||
- | |||
- | |||
- | |||
Line 263: | Line 260: | ||
// of JavaScript arrays | // of JavaScript arrays | ||
</code>| | </code>| | ||
+ | |||
====Indexing by name – AS records and JS objects==== | ====Indexing by name – AS records and JS objects==== | ||
to follow ... | to follow ... | ||
+ | |||
====Structuring scripts – branching, nesting, mapping, filtering and reducing==== | ====Structuring scripts – branching, nesting, mapping, filtering and reducing==== | ||
Line 276: | Line 275: | ||
=====Accessing Keyboard Maestro Variables===== | =====Accessing Keyboard Maestro Variables===== | ||
- | You can access Keyboard Maestro variables from JXA scripts using the Keyboard Maestro Engine application. | + | You can access Keyboard Maestro variables (7.1+) from JXA scripts using the Keyboard Maestro Engine application. |
<code javascript> | <code javascript> | ||
var kme = Application("Keyboard Maestro Engine"); | var kme = Application("Keyboard Maestro Engine"); | ||
kme.getvariable('Var'); | kme.getvariable('Var'); | ||
- | // kme.setvariable('Var', { to: "Hello There World!" }); | + | kme.setvariable('Var', { to: "Hello World!" }); |
</code> | </code> | ||
+ | |||
+ | JXA can get a list of all variables as described on the [forum](https://forum.keyboardmaestro.com/t/using-km-variables-in-yosemite-javascript-for-applications-jxa/889) and those methods also provide more convoluted ways to access variables for versions prior to 7.1. | ||
=====The Automation interface===== | =====The Automation interface===== | ||
Line 313: | Line 314: | ||
to follow ... | to follow ... | ||
+ | |||
+ | ===== See Also ===== | ||
+ | |||
+ | ---- | ||
+ | |||
+ | === Actions === | ||
+ | |||
+ | * [[action:Execute a JavaScript For Automation|Execute a JavaScript For Automation]] | ||
+ | * [[action:Execute a JavaScript in Custom Prompt|Execute a JavaScript in Custom Prompt]] | ||
+ | * [[action:Execute a JavaScript in Google Chrome|Execute a JavaScript in Google Chrome]] | ||
+ | * [[action:Execute a JavaScript in Safari|Execute a JavaScript in Safari]] | ||
+ | * [[:Actions|See all Actions]] | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ==== Forum ==== | ||
+ | |||
+ | - [[https://forum.keyboardmaestro.com/t/using-km-variables-in-yosemite-javascript-for-applications-jxa/889|Using KM variables in Yosemite Javascript for Applications (JXA)]] | ||
+ | - [[https://forum.keyboardmaestro.com/t/how-to-change-safari-web-inspector-font/3655|How to Change Safari Web Inspector Font]] | ||
+ | |||
+ | - [[https://www.google.fr/search?q=site:forum.keyboardmaestro.com+JavaScript+for+Automation+JXA|Keyboard Maestro Forum topics about JavaScript for Automation]] |