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
1 answer

JXA: display dialog with custom icon

With AppleScript, we can easily display a dialog with a custom icon: display dialog "Test" with icon POSIX file "{{path_to_our_icon}}" How can we do the same with JXA (JavaScript for Automation)? The official documentation doesn’t seem to cover…
user137369
  • 5,219
  • 5
  • 31
  • 54
0
votes
1 answer

Create a new path item in Adobe Illustrator via JXA (JavaScript for Automation)

I'm looking for a way to create path items in Adobe Illustrator using JXA (JavaScript for Automation). I googled the whole internet several times and couldn't find anything... There is only a very basic introduction of JXA on the Apple Developer…
0
votes
1 answer

Reveal In Finder Using JXA (Javascript for Automation on Mac)

I am converting some of the automator workflows I made over the years into JXA and I am having some trouble with some basic functions. Firstly, I am simply trying to open a folder in finder from a specific path. I came across this link for opening a…
0
votes
1 answer

Replace fonts in Keynote with JXA

I'm trying to find/replace problematic fonts in Keynote, and found this script to change fonts using JXA, but need to scan every character and text object for the offending font. I've tried this to start, but the conditional isn't working.…
0
votes
0 answers

How do I automate my workflow with Javascript to save bunch of images

I am trying to copy paste some stuff from some website which I want to automate. Here is my manual workflow: There is a master webpage which contains set of links. When I click on one of those links it opens another (say topic page) page with set…
MsA
  • 2,599
  • 3
  • 22
  • 47
0
votes
1 answer

Quit a Mac application from a JavaScript for Automation (JXA) script

The AppleScript way to quit a Mac application is: tell application "iTunes" quit end tell How do you quit an app with JavaScript for Automation (JXA)?
Alan W. Smith
  • 24,647
  • 4
  • 70
  • 96
0
votes
1 answer

img.lockFocus is inaccessible via ObjC bridge?

I'm trying to create a purely JXA-ObjC approach to getting pixel colors from image paths. Here's what I have currently: ObjC.import('Foundation') ObjC.import('AppKit') var c_filePath = $(picturePath) var c_img =…
Sancarn
  • 2,575
  • 20
  • 45
0
votes
1 answer

JXA: how to make a new sheet in a document in Numbers.app

I'm using JXA to automate a process using Numbers app. What is the syntax to create a new sheet in an existing document? var Numbers = Application('Numbers'); Numbers.documents[0].Sheet()... The AppleScript equivalent would be: tell application…
0
votes
1 answer

deselect all in Finder using JavaScript for Automation

Playing around with JavaScript for Automation, I find myself not able to do something that is very simple in AppleScript. (Shocker, I know.) This AppleScript: tell application "Finder" to set selection to {} clears the selection in Finder. I just…
Patrick Wynne
  • 1,864
  • 15
  • 20
0
votes
0 answers

Automating OSX with script fails to eject DVD when script is called from Apple > Preferences > CDs and DVDs

I set "Apple > Preferences > CDs and DVDs > When you insert a video DVD" to run my script written in AppleScript or JavaScript. My script for testing this calls a shell command to eject the DVD: drutil eject //JXA version var app =…
Buoy
  • 795
  • 1
  • 8
  • 13
0
votes
1 answer

AppleScript JavaScript Can't Export As Run Only

If I export AppleScript written in JavaScript as run only, I can open back in Script Editor. It also shows all the source code. However, if I export regular AppleScript as run only, I can't open it nor look at the source code using other text…
chibop
  • 119
  • 9
0
votes
1 answer

AppleScript JXA Filtering Table With Many Rows with Same Name But Different Items

I have a huge table with many rows that have same name but different items in each row. If I execute the following rows = table.rows.whose(searchFilter)() And then if I check rows.length, I get the right number for the search. However, the…
0
votes
1 answer

How do I get actual class of JXA object

I’m trying to differentiate between iTunes playlists that are folders and ones that aren’t. In AppleScript there seem to be two ways to do this: I can get all folder playlists and process them individually from user playlists: set userPlaylists to…
Raphael Schweikert
  • 18,244
  • 6
  • 55
  • 75
0
votes
1 answer

Building Applescript ObjectSpecifier With Name in Javascript

Is there a way to build an ObjectSpecifier using name instead of array number in Javascript Applescript? search = ObjectSpecifier().buttons["Add"].value items = items.groups.whose({_match:[search,"Selected"]}) The index for "add button" is…
chibop
  • 119
  • 9
0
votes
1 answer

use objC bridge Contacts framework in JavaScript for Automation

How do I use the ObjC bridge Contacts framework in JavaScript for Automation? I am able to use the old AddressBook framework, but not the Contacts one. Let's say I have an ID: id = Application("Contacts").myCard().id() The old AddressBook…
wivku
  • 2,457
  • 2
  • 33
  • 42