Questions tagged [javascript-automation]

JavaScript for Automation (JXA) provides users with the ability to use JavaScript for interapplication communication between apps in macOS.

1
vote
0answers
24 views

AppleScript : to do Javascript action in Safari repeatedly

I created this script to highlight some data points in Safari. This was working fine but I had to restart the script often as shorting the data in a different order remove all the highlight ... I ...
2
votes
2answers
118 views

JXA JavaScript for automation How to make JXA click something

What is the JXA equivalent of --AppleScript tell application ("System Events") click at(x,y) end tell
2
votes
1answer
52 views

Detect if ctrl key is pressed

In JavaScript for Automation (JXA), we can detect if the ctrl key is pressed with ObjC.import("Cocoa") $.NSEvent.modifierFlags & $.NSControlKeyMask If ctrl is not pressed, the return will be 0. ...
2
votes
0answers
60 views

highlighting text in safari

I need to highlight every instance of some keywords in Safari. I have this script which work : set myList to {"demo", "demo1"} try tell application "Safari" do JavaScript "document....
9
votes
1answer
113 views

Open and focus file browsing dialog from command line

I'd like to open the native file browsing dialog from the command line, focus the dialog, and then get the full path of the selected file. The following works nicely, but the dialog is not focused ...
1
vote
2answers
167 views

document.querySelector with AppleScript / Safari

I need a script to open each tab in safari when I get "valueIneed" from an internal website here is the HTML tag <td class="orderDetails"> <p class="details"> (My ...
2
votes
1answer
149 views

How can I use a keyboard shortcut to run two or more keyboard shortcuts

I'm using Due app on the mac, and I'm wondering if it's possible to have one keyboard shortcut to run the app, reset the running timer ( command+ shift+ s) and then run the timer again (command + S) ...
3
votes
1answer
246 views

In AppleScript or JavaScript how can you click menu item?

I need to change a theme using a script for Mojave, Alfred and Sourcetree. I've already successfully done this with Mojave and Alfred using this script: var alfredLightTheme = "Alfred" var ...
0
votes
1answer
91 views

Applescript javascript multiple line

How can we add multiple line text in Chrome using document.getElementsByClassName? I have no issue when it's one line but one I have more than one I have a missing value instead set myCaseNote to "...
3
votes
1answer
141 views

Applescript & Javascript to get number from chrome and give a total

I'm trying do get every totals from an internal webpage and get the total. for getting a single result I wrote this : tell application "Google Chrome" tell tab 1 of window 1 to set orderTotal to ...
0
votes
1answer
171 views

Applescript fill up chrome textfield class

<div class="content" contenteditable="true" data-placeholder="Search Cases" data-maxlength="" data-div-placeholder-content="true">mytexthere</div> I don't manage to fill up the text from ...
2
votes
0answers
116 views

Modify a reminder (Reminders.app) with JXA

I have a specific reminder that runs every day. The time at which that reminder should fire changes frequently (about once a week). instead of manually changing it every time, I’d like to run a script ...
1
vote
1answer
461 views

Renaming files with a RegEx search, preferably via JXA

I have a two part question here. I'm trying to make an automator service to quickly rename files. My job uses a file name syntax of 1234-01a-FileName.psd where 1234 is the job number, 01 the file ...
2
votes
1answer
92 views

Cannot concatenate text in JXA

I am trying to get on the Javascript for Automation bandwagon. I wrote a quick script that automates my travel request email, with a few dialog boxes. Here is my code: Mail = Application("Mail"); ...
2
votes
4answers
2k views

AppleScript alternatives

I've recently discovered AppleScript. AppleScript affords a simple, natural way to programmatically simulate keyboard-and-mouse interaction with Mac applications. AppleScript is great, however it ...
5
votes
2answers
663 views

Output JXA to stdout

I have a small script made with JXA (JavaScript for Automation) that outputs a result to the shell with console.log. However, console.log seems to output to stderr and I’d like to output to stdout. I ...