javascript-automation

Trigger a script (AppleScript or JXA) on .app running?

醉酒当歌 提交于 2021-02-08 06:33:13
问题 I have a small computer lab for students to use fairly unsupervised, with a printer attached on the network. I am trying to implement a simple scripting additions alert dialog with all the rules about the printer that I need to pop up when they select print from any number of different applications. I am trying to attach the script directly to the printer itself in the User/Library/Printer directory, (xxx.xxx.xxx.xxx.app) so any browser, or pdf viewer, etc. will get the message displayed when

javascript automation click download button in iTunes

非 Y 不嫁゛ 提交于 2021-02-07 10:31:28
问题 I need to programatically download an app from iTunes using JXA. I've done the following: var its = SystemEvents.processes.byName('iTunes'); delay(3); its.windows[0].buttons.byName('Get').click(); There is no element selected. I've tried clicking on buttons[0...7] and none of those are the 'Get' button. I assume the button I need is inside a document, biut the JXA documentation clearly states that button elements are children of Window, not of Document. Any ideas on how to click on the

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

白昼怎懂夜的黑 提交于 2021-01-29 17:26:17
问题 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 runs in Script Editor: contacts = Application('Contacts').people; matchingAddresses = contacts.addresses.whose({city: "San Diego"}); var addressIds = []; for (var matchedAddress of matchingAddresses()) { if (matchedAddress.length > 0) { addressIds

Accumulate all JS warnings and errors during test runs in TestCafe

我只是一个虾纸丫 提交于 2020-08-08 18:00:13
问题 I would like to be able to access all JS warnings and errors from the Browser Console during test runs. With the "-e" (skip JS errors) flag disabled, the test stops at the first error, so clearly it is looking for them. With this flag enabled, I would like to be able to see which errors (and ideally warnings) fired during test runs. I've tried using the ClientFunction and window.onerror methods. I've also tried the -r 'reports' flag -- I only see TestCafe errors, not JS errors from the page

How to translate this slider value change from AppleScript to JavaScript

给你一囗甜甜゛ 提交于 2020-01-17 06:20:09
问题 This bit of AppleScript works. If I have the System Preferences Sound panel open, and run it in the Script Editor app, it changes the volume to be at 50%. tell application "System Events" tell process "System Preferences" set v to value of slider 0 of window 0 log v set value of slider 0 of window 0 to 0.5 end tell end tell This, which tries to be the same thing, fails. Anyone know how to fix it? var se = Application("System Events"); var spp = se.processes["System Preferences"]; spp.windows

Send Mac OS X Notification Center message via JavaScript - 10.10 Yosemite

限于喜欢 提交于 2020-01-15 07:58:10
问题 How can a message be sent to the Mac OS X Notification Center using the JavaScript for Automation functionality that was introduced in 10.10 Yosemite? 回答1: Messages can be sent to Notification Center via Automator and Script Editor JavaScripts by using the includeStandardAdditions method from the core library. For example: app = Application.currentApplication() app.includeStandardAdditions = true app.displayNotification('Basic message') The Script Editor application has documentation that