Questions tagged [osascript]

MacOS command line tool which executes OSA scripts (AppleScript, JavaScript, etc.)

267 questions
0
votes
3 answers

How to use global variables inside of an Applescript function for a Python code

How would I call a global variable from my python script inside of the tell application? Here's a sample of where that might go. Say I wanted to change all "front window" from outside of the applescript from a global python variable. How might that…
0
votes
2 answers

Lists and repeating numbers in AppleScript

I want to write a script in AppleScript that will output all numbers from 0000 to 9999 in turn to an application (here it is System Preferences) using the keystroke command. I have this so far that will do one number: tell application "System…
0
votes
1 answer

Getting osascript applescript to untick checkbox finder extensions in system preferences

I have tried looking through many answered questions and wasn't able to fix my specific issue, the issue is telling applescript to look through Extensions in system preferences and untick this check box I am unable to help applescript locate the…
0
votes
0 answers

Displaying a progress dialog with osascript - why is this sample from Apple not showing a dialog?

I think I've read just about every question here on applescript dialogs with progress bars and I'm still not getting something. Specifically this sample from Apple, I have copied the code and compiled to a test.scr and when I run it with osascript…
spartygw
  • 3,289
  • 2
  • 27
  • 51
0
votes
1 answer

Can't send keystrokes from Terminal to app using osascript in MacOS

I have TextEdit open. I want to enter "hello" in TextEdit, but not by typing it in myself, but using a command from Terminal. I tried this: osascript -e 'tell application "TextEdit" to keystroke "hello"' but it give the following error: 31:48:…
Hamid
  • 90
  • 1
  • 7
0
votes
1 answer

how do you force apple script + aws vault to wait for mfa access

I have an apple script like this #!/bin/zsh tell application "iTerm" activate select first window # Create new tab tell current window create tab with default profile end tell # Split pane tell current session…
sf8193
  • 575
  • 1
  • 6
  • 25
0
votes
2 answers

How do I pass labeled (or named) parameters to an existing AppleScript script file via the command line (using osascript)?

My Problem I have an AppleScript script file called script.scpt. This is the first line of the script where I'm intending to use labeled parameters (AKA named parameters): on run given foo:fooStr I open Terminal and attempt to run the script by…
Art Geigel
  • 1,915
  • 3
  • 22
  • 24
0
votes
0 answers

Osascript & iTU

My python code, import subprocess command = ['osascript', '-e', 'tell application "iTunes" to name of current track as string'] p = subprocess.check_output(command) When i run this i get a FileNotFound error, FileNotFoundError: [WinError 2] The…
xSavgs
  • 32
  • 1
  • 4
0
votes
3 answers

How to cron an AppleScript (with arguments) that accesses Reminders

I wrote an AppleScript to synch my Reminders (via export to JSON). It runs great... from the Script Editor. As soon as I tried to run it on the command line via osascript, I discovered it hits a wall when it tries to access reminders. After maybe…
hepcat72
  • 890
  • 4
  • 22
0
votes
1 answer

How to fix "original file could not be found" error via apple script

I have an issue with my music library. Some songs I am unable to play because they cannot be found locally. Here's an example of the error messages I get when playing a specific song: The song ... could not be used because the original file could…
calpyte
  • 855
  • 1
  • 9
  • 17
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
1 answer

Triggering a notification from within a bash script

Target devices: macOS Catalina and higher I could use some help fixing a problem in a script that is supposed to trigger an osascript notification whenever a user tries to connect to a banned SSID. The notification should only occur when the user is…
notarobot
  • 23
  • 4
0
votes
0 answers

How to properly (quickly) iterate over Reminders using AppleScript/osascript?

What is the proper, efficient way to iterate over Reminders using AppleScript? The script below works as expected, but takes 18 seconds to iterate over 180 Reminders when run from the command line using osascript! (This same script takes only 2-3…
Zack
  • 6,232
  • 8
  • 38
  • 68
0
votes
0 answers

how to know inform shell script that apple script / automator workflow has finished?

Problem: I want to make a shell script that exports all contacts inside the macOS's address book to a specific folder (for backup purposes). To do that, I want to use a simple automator workflow or apple script. However, I need to know when that…
WalterBeiter
  • 2,021
  • 3
  • 23
  • 48
0
votes
1 answer

How to wait for osascript to produce a result

sometimes my AppleScript code seems to fail, on other machines is works. I run this AppleScript code as heredoc from inside a shell script. The shell script is a postinstall script run by a pkg installer and runs as root: #!/bin/sh set…
Robert
  • 160
  • 9