Questions tagged [javascript-automation]

an environment for scripting Mac applications using JavaScript. Available in OS X Yosemite and later, this is a newer companion to the traditional AppleScript environment, and targets the same underlying OSA object model. Sometimes abbreviated as JXA.

JavaScript for Automation is an environment for scripting Mac applications using JavaScript. Available for the first time in OS X Yosemite, this is a newer companion to the traditional AppleScript environment, and targets the same underlying OSA object model. JavaScript for Automation is sometimes abbreviated as JXA.

Apple's documentation as of this writing consists of release notes only, with the release notes for Yosemite describing the language features and providing examples on a single, lengthy page.

253 questions
0
votes
0 answers

Calling Node.js from AppleScript or JXA

I need a very simple example to call my local installed node.js and all the installed modules from AppleScript or JXA (JavaScript Application Scripting). I tried in JXA: var app = Application.currentApplication() app.includeStandardAdditions =…
0
votes
1 answer

Objective-C/Cocoa to JXA

I need to convert a PNG file to Base64 data so that I can add it to a JSON object, using JXA (JavaScript Application Scripting). JXA is limited compared to regular JavaScript so I can't immediately use functions from FileReader, etc. From what I've…
PE B
  • 65
  • 4
0
votes
0 answers

Javascript: Place Image Onto Adobe Illustrator Artboard Using Finder Selection

I'd like to place an image onto an Adobe Illustrator artboard using an image file selected in Finder. Can this be done using JavaScript? var FINDER = Application("Finder"); FINDER.includeStandardAdditions = true; var ImageA =…
0
votes
1 answer

Why can I only access window.properties() when running from within Automator?

I am trying to write a JXA script which extends the bounds the current window of the current application vertically so it reaches from the top to the bottom of the screen. If I run the following script in Automator as a "Run JavaScript" quick…
matvore
  • 792
  • 6
  • 10
0
votes
1 answer

How do you select mail messages using JXA script

To select messages in Mac Mail using AppleScript you can use the following syntax: tell application "Mail" set selectedMessages to selected messages of the first message viewer set selected messages of the first message viewer to item 1 of…
McShaman
  • 3,627
  • 8
  • 33
  • 46
0
votes
1 answer

How do I get (people whose id of addresses contains addressId) in JXA?

I’m using JavaScript with osascript, on MacOS Mojave 10.14.3, to write a script that displays people and their contact information from Contacts. I’m adding a function to show all of the people in a particular city. Here’s a simplified version that…
Jerry Stratton
  • 3,287
  • 1
  • 22
  • 30
0
votes
1 answer

displayDialog method return value causes error -1700 when used as string argument

When I try printing the Var 'password' it says Error -1700: Can't convert types. var app = Application.currentApplication(); app.includeStandardAdditions = true; var text = Application('System Events') //prompt var password =…
0
votes
1 answer

Documentation on Application.launch() in JXA?

Where can I find documentation on Application.launch() in JXA? Application('Safari').launch(); It seems Application.launch(), unlike Application.activate(), only starts the application process without actually open or activate an application…
Zhen Yao
  • 51
  • 5
0
votes
1 answer

Trying to list out accounts on Outlook 2016 Mac using JXA AppleScripting

var outlook = Application("Microsoft Outlook"); Then what, the documentation is so bad. I have tried to use a number of ways to expore the object using .Account and .account and .Accounts and returning and trying JSON_Stringify to explore but no…
koconder
  • 151
  • 7
0
votes
1 answer

How to fix "Error on line 72: Error: sh: img2pdf: command not found"

Here is the error I have in Script Editor: Error on line 72: Error: sh: img2pdf: command not found I'm writing a JavaScript for Automation (JXA) script to automate online math homework collection after asking that question. The script is finally…
Ying Zhou
  • 189
  • 3
  • 16
0
votes
1 answer

Cleanup Apple Mail folders with JXA

I want to write a JXA script which automatically deletes old mails from my folders. I found a solution, but it is very slow and I'm wondering if there is a way to speed this up. Here is my script: mailApp =…
0
votes
1 answer

MacOS Contacts details using JavaScript vs AppleScript

I'm trying to get all the email addresses of the selected card in Apple's Contacts.app. In either language I can get the selected card into the variable selPerson. But then... In AppleScript this works: get the properties of every email of…
UKenGB
  • 21
  • 2
0
votes
1 answer

How to make new document with JXA?

How to make new document and close? Need this to workaround apple automation buggy insanity. What I try is this: var app = Application('Keynote') var doc = app.make(new document) // How to write this correctly? doc.close({saving: 'no'})
Jonas
  • 4,683
  • 4
  • 45
  • 81
0
votes
2 answers

How Do I Get JavaScript Code Completion (Intellisense) in JXA File in Visual Studio Code?

It is great that this extension provides us with the ability to code, compile, and run JXA files: AppleScript & JXA for Visual Studio Code Unfortunately, JavaScript code completion is not active for a JXA file, even though JXA uses core JavaScript. …
JMichaelTX
  • 1,659
  • 14
  • 19
0
votes
1 answer

JXA for Mac Automation Watching Folders

Is it possible to watch folders with a JXA script on Mac? I am trying to figure out how to detect a folder was opened and run a JXA script. Apple has a javascript version of most things in their guide, but not this page:…
Paul
  • 189
  • 1
  • 9