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
1
vote
3 answers

Open new Terminal Tab with OS X JavaScript for Automation

I am playing around with JavaScript for Automation on OS X Yosemite. I am trying to open up a new tab in the terminal application. Here is what I've got so far: var Terminal = Application('Terminal); var Tab = Terminal.Tab; // Activate the…
tytho
  • 237
  • 2
  • 10
1
vote
2 answers

Call Objective-C from Safari javascript?

On OSX (say Yosemite), I'd like a way to call Objective-C from Safari/Javascript. Is there a way to do this? Not what I'm looking for: embed a WebView/WKWebView in an app Start/control/load Safari from Objective-C use JXA outside of Safari (unless…
Clay Bridges
  • 11,602
  • 10
  • 68
  • 118
1
vote
1 answer

JavaScript for automation in OSX Yosemite

Can we send a click event to a button inside a webview in Cocoa app using JavaScript? I am trying to use the script editor under utilities (Yosemite) to record but unfortunately not able to record any events inside the webview. I tried using the…
samn
  • 13
  • 4
1
vote
1 answer

XML parsing syntax for OS X Yosemite JavaScript for Automation?

Has anyone deduced syntax which successfully loads XML from file/string and gives access to the data in OS X Yosemite (10.10) Javascript for Automation ? Documentation and code samples are still fairly thin (as of Nov 2014), and my inductive skills…
houthakker
  • 688
  • 5
  • 13
1
vote
0 answers

How do I add an iCal event using JS automation in OS X Yosemite?

I'm really having a hard time understanding how to interact with iCal using the new support for Javascript automation in Yosemite. I'm not too experienced with OOP so that might be where my problem lies. Could someone help me out with the code for…
Brian Peters
  • 297
  • 1
  • 3
  • 17
1
vote
1 answer

How to get NSTableView To Load With Javascript for Automation

I guess I'm living on the edge trying on OS X Yosemite to get a NSTableView to populate using JavaScript via the ScriptEditor. I can get the table to show up and number of rows are being set correctly however the actual data is not be loading in…
0
votes
0 answers

Executing VoiceOver Command in JXA

The following AppleScript works. tell application "VoiceOver" tell commander to perform command "item chooser" end tell However, the following JXA throws an error: "Error 6: An error occurred." vo =…
0
votes
0 answers

How to write AppleScript or JXA to click a Safari permission dialog button

I am trying to automate clicking Allow for camera and microphone access in Safari when prompted. I have a TestCafe automated test that runs on Safari and I encounter the following camera and mic permission dialogs once the test starts: I have…
0
votes
1 answer

Check if background value exists for JXA/Applescript for Numbers

I'm using JavasScript to write the script for Numbers automation. I believe its called JXA in this context? Based on: https://leancrew.com/all-this/2022/05/javascript-vs-applescript/ Anyway here's a function that colorize the row based on a…
hackerl33t
  • 2,117
  • 3
  • 14
  • 21
0
votes
1 answer

Delete Subfolders in Photos via Applescript or JXA not possible?

I'm stuck, since I found no way to delete a subfolder in Apple's Photos. Neiter via Applescript nor with JXA. The deletition of folders on top level is no problem, but trying to delete subfolders (folders within folders) always results in an error,…
0
votes
0 answers

How to determine if an app is at the side of the stage manager in macOS Ventura

I have a JavaScript for Automation (JXA) function to determine which state a macOS app is currently in: function getAppState(appName) { if (!Application(appName).running()) { return "APP_NOT_RUNNING"; } const proc = Application("System…
Patrick Hund
  • 19,163
  • 11
  • 66
  • 95
0
votes
1 answer

JXA keystroke does not work with numbers?

I would like to trigger a keyboard shortcut using JXA. This works: system.keystroke('d', { using: ['control down', 'option down'] }) But this does not: system.keystroke('3', { using: ['control down', 'option down'] }) The difference being the…
Ivan Bacher
  • 5,855
  • 9
  • 36
  • 56
0
votes
1 answer

Webdriver.IO[7] : How to check current iframe context before switching to any other iframe

I want to click element inside the iframe. I would like to know the current iframe context or How many iframe present before switching to any other iframe. How to check current iframe context in WDIO[7]? I have tried below code. await…
0
votes
0 answers

Adding a music to Apple Music Library using Apple Script

I have an AppleScript, which duplicates the currentTrack to my AppleMusic Library. Although, it seems that the Library has a capacity of (length of the library + 1), and whenever I add a new track using the duplicate this capacity is not increased.…
KadoBOT
  • 2,944
  • 4
  • 16
  • 34
0
votes
1 answer

JXA: Manipulating windows by their ID

Instead of Application("Preview").windows[0].bounds = {"x": 1440, "y":25, "width":1440, "height": 2535} I'd like to move the window but instead of using an index, I'd like to use the window's ID. I got the ID…
Xehelios
  • 111
  • 1
  • 1
  • 4