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

What would the equivalent code be in JXA for getting the URL from a Firefox browser?

tell application "System Events" to get value of UI element 1 of combo box 1 of toolbar "Navigation" of first group of front window of application process "Firefox" I am using the above in an AppleScript to get the URL from the Firefox browser,…
Huckerby
  • 1
  • 1
0
votes
1 answer

JavaScript for Automation (JXA) Excel open workbook question

How do you open an Excel workbook using JavaScript for Automation? let excelApp = Application("Microsoft Excel"); let path = Path("/Users/me/Test.xlsx"); excelApp.openWorkbook(path); gets error 50 "parameter error".
hustlefan
  • 1
  • 3
0
votes
0 answers

Get list of window names for all running applications

Using the following block of code Application("System Events") .applicationProcesses.where({ backgroundOnly: false })() .forEach((app) => { app.windows().forEach((window) => { console.log(window.name()); }); }); I can access…
Espresso
  • 740
  • 13
  • 32
0
votes
1 answer

Applescript/JXA: How to set UI element to focused?

I am writing an AppleScript using Javascript (JXA) that uses Finders search bar to find files. I want to move the focus from the search text field onto the file listing (so that arrow buttons and space for preview works). I have tried a few…
zino
  • 1,222
  • 2
  • 17
  • 47
0
votes
1 answer

I can't get Delete Row/Remove to work in Mac Numbers with JXA

I have written a JXA script for Numbers that coverts a standard eCommerce order spreadsheet to the Stamps.com format for uploading the order, to print shipping labels. After 2 weeks of digging for info on JXA for Numbers, I have the conversion at…
Ndna Jnz
  • 3
  • 2
0
votes
4 answers

JXA set window bounds weird issue

script1.js: function run() { const chromeApp = Application('Google Chrome'); const window = chromeApp.windows[0]; console.log(window.name()); window.bounds = { x: 0, y: 0, width: 500, height: 500, }; …
Tyler Liu
  • 19,552
  • 11
  • 100
  • 84
0
votes
1 answer

Register Javascript reply from JXA

Back again with a JavaScipt / JXA question. I'm trying to register a response from a application that I'm calling with JXA. I am trying to register the value app.toDos.byId("HQebK1em72yZqc3WqTmyzx"). When I kick of the following script: var TaskApp…
0
votes
1 answer

Can I access Image Suite in a JavaScript workflow?

I want to write a simple Automator action to scale an image to an an arbitrary percentage. Using the standard Automator actions, I don’t think that’s possible - I need to set the size in the action itself. My thought is that by adding a Run…
Manngo
  • 14,066
  • 10
  • 88
  • 110
0
votes
1 answer

JXA: Get just-clicked on window (in focus window)

Using Javascript for Automation (JXA) I want to identify the window the user has just clicked on. In other words, I want to identify the window that has just come to the front. How can I do that? So far, I identify the front application, and try to…
SeanRtS
  • 1,005
  • 1
  • 13
  • 31
0
votes
0 answers

Security & Privacy and self-modifying applications

A friend and I are developing an application with electron. This application has settings which are currently being stored in the application LaunchMenu.app. Within this application we are using the following JXA script to execute keyboard…
Sancarn
  • 2,575
  • 20
  • 45
0
votes
2 answers

Getting table name from cell selection in Apple Numbers using Javascript for Automation (JXA)

I'm trying to convert this Applescript to Javascript for Automation. Is there anyone who can help to write the line bellow in Javascript for Automation? set thisTable to the first table whose class of selection range is range Appreciate any help!
wchongo
  • 31
  • 4
0
votes
1 answer

JXA script stops running when my macbook goes to sleep

I am running a JXA script as an agent using launchctl. The main logic of the script is supposed to be run at intervals of 2 seconds, which I have achieved using an infinite loop and delay. However, whenever my macbook goes to sleep the script stops…
Shubham
  • 352
  • 3
  • 14
0
votes
1 answer

cant submit a form using puppeteer in javascript

i need to submit a job post form in a website.I have done Authentication part successfully but after logging in i need to submit a job post form i dont know how to submit the form please help me with that. const puppeteer =…
0
votes
0 answers

Trying to use ObjC with JXA: TypeError on simplest example

I'm trying to use ObjC with JXA. Here is a simplest possible example: ObjC.import('Foundation') str = $.NSString.alloc.initWithUTF8String('foo') console.log(str) This code gives me an Error: TypeError: undefined is not an object (evaluating…
0
votes
0 answers

How can I script the sorting of Reminders.app?

I am looking for ways of sorting my Reminders.app lists so that the order gets propagated to my various iCloud synced devices. I can do this manually, but it takes a very long time and quite tedious with multiple lists. I would like to be able to…