Questions tagged [osascript]
MacOS command line tool which executes OSA scripts (AppleScript, JavaScript, etc.)
266
questions
1
vote
0
answers
51
views
How are my Apple Scripts saved on Google Drive being corrupted?
Note, I'm not asking what I should do, or how to fix this problem, or why saving AppleScripts in Google Drive is a bad idea - I already know that and have a solution to my problem. I understand it ...
0
votes
0
answers
27
views
Osascript Music get current track shareable url
Is there a way to get the shareable URL for the current track playing via osascript?
For instance: https://music.apple.com/br/album/never-gonna-give-you-up/1558533900?i=1558534271&l=en-GB
Thanks ...
-2
votes
1
answer
33
views
Can I "tell" the Apple "Preview" application to scale an image up or down via Apple `osascript`?
I want to script the "Preview" application to do the equivalent of clicking the + or - button in the app, which when hovered over give the text "Scale document up" (and down). Is ...
0
votes
1
answer
47
views
AppleScript handlers with whitespace in parameter names and without "given"
I read about interleaved- handlers and parameters in handlers in Apple's documentation, but I don't know why some specific open-source code is working for others while not for me.
In the documentation ...
0
votes
0
answers
66
views
ZSH osascript tell parent application (process) display dialog
I have an AppleScript application that runs a do shell script of my script.sh in the application package.
That my script.sh does some interaction with the user through
$osascript -e 'tell me to button ...
2
votes
0
answers
34
views
How to use osascript to open Iterm2 and run script?
Currently, I have an sh file which I use to run a script as such:
osascript -e "tell application \"Terminal\" to do script \"cd $PWD && npm run build:watch\""
...
1
vote
2
answers
632
views
Tauri - Run bash Script - Example
I'm new to Tauri and Rust in general.
I'm working on this desktop app that will run different bash commands such as:
returning some outputs
open a new window (terminal) to run a process with output ...
0
votes
1
answer
93
views
Is it possible to monitor incoming calls on a connected iPhone and send automated responses via a Mac app?
I need to include in my app a way to monitor whenever an incoming call takes place, which won't be answered by anyone; and then send a customized automated response to the caller using Messages app.
...
0
votes
0
answers
18
views
Opening a dialogue from the terminal
I've been struggling trying to open an alert popup to MacOs users using the terminal.
The script is been ran using an MDM solution, so I need to check which user is active before running it. I tried ...
1
vote
1
answer
69
views
Apple script in GitlabRunner failing Error code -600
I'm working on a project involving Apple Script and I can not manage to set it up correctly in the GitLab runner. No matter what I do it seems the gitlab-runner does not see any running applications, ...
0
votes
0
answers
62
views
MacOS - Add a Server to the saved servers list with command line
I'm trying to get a server into the "Favourite Servers" section.
Favourite Servers
The catch is: I want to do it with the terminal using "osascript" or "defaults write"
I ...
0
votes
0
answers
84
views
MacOS - Automation setting gets unchecked on its own
System: macOS Monterey 12.0.1
I'm having an issue with my automation using osascript and I can't seem to find the way to solve it. I want to run a osascript code that will tell the System Events ...
0
votes
0
answers
53
views
Is there a way to get the list of applications in the Application Switcher in the same order using osascript?
I'm trying to use osascript to get the list of applications that appear in the application switcher (forgive me if that's not the correct name, but what appears when you run cmd + tab)
osascript -e '...
0
votes
1
answer
72
views
Displaying an Xcode variable in a shell script in an alert fails to display the alert
I have a shell script that I run from Xcode to open the root folder in the Terminal. It works as expected when invoked by a function key in Xcode and opens a Terminal window pointing to the value of ...
0
votes
0
answers
63
views
How do I invert screen colors in Mac with a command line?
I would like to invert the screen colors with a script (osascript, bash, applescript or even with something in C code).
The closest thing I have found is toggle the dark theme.
> osascript -e 'tell ...
0
votes
2
answers
200
views
How to change volume on mac using osascript and OpenCV
I'm using a 14 inch M1 Pro Macbook Pro, running Mac OS Monterey 12.6.
I'm making an OpenCV and Mediapipe based Computer Vision Project that allows me to use hand detection to control my Mac's volume. ...
0
votes
0
answers
120
views
Allow AppleScript to run without asking for Permissions Monterey
I was wondering if there was a way to allow Applesript to run without asking for the initial pop-up permissions on Monterey?
Or is there a way to automate the acceptance of the pop-up permissions? ...
-1
votes
1
answer
73
views
How can I get a list of the available themes for Terminal on OSX?
I would like to get the list of available Terminal themes, i.e. Basic, Grass, Ocean etc., using a bash script.
0
votes
0
answers
71
views
Run two processes in two different shell tabs automatically
I am making a shell script that starts the frontend and backend development servers for my node app. This means starting one server, opening a new tab, and starting the other.
The problem with my ...
1
vote
1
answer
233
views
Communicating with root child process launched with osascript "with administrator privileges"
How can I pass messages between a parent process that launches a child process as root using Apple Script and stdin/stdout?
I'm writing an anti-forensics GUI application that needs to be able to do ...
-1
votes
1
answer
43
views
Why does my desktop background does not change after executing Python script?
I followed this tutorial for changing the background on my macOS Monterey 12.5. When I run the Python script my background ist not changing but I also don't get an error message.
In System Preferences ...
0
votes
3
answers
354
views
Run 2 commands in applescript/osascript with variable
I am trying to run 2 commands stored in a variable with osascript
This is my start.sh
currentDirectory="cd $(pwd) && npm run start"
echo $currentDirectory
osascript -e 'tell ...
1
vote
0
answers
470
views
Notifications via cron (MacOS)
I've got a script which disables Internet Sharing function on Macbook, then sends a GUI notification via osascript and an email.
It works perfectly, but i don't get notifications when it run in cron.
...
-1
votes
1
answer
181
views
reload Terminal preferences .plist after change
I used plutil to edit the plist. then I placed in under /User/<myUsername>/Library/Preferences/com.apple.Terminal.plist. I want it to update the settings without reboot the application. How do I ...
-2
votes
1
answer
1k
views
How to tell terminal to do script in window I just opened
I tried this
tell application "Terminal"
set custom to open "/Users/jredfox/Desktop/h.terminal"
do script "/Users/jredfox/Desktop/test.sh" in custom
activate
...
-2
votes
1
answer
471
views
How can I run osascript with python on MacOS?
How can you add login item in system preferences with python using osascript or any other method on macos,
Is this process right?
subprocess.call("osascript -e add login items to System ...
1
vote
1
answer
506
views
MacOS desktop background won’t change
I was playing around with a python script that downloads and changes the wallpaper, and suddenly the wallpaper went black and won’t change even through the preferences menu. The dock also stopped ...
-1
votes
2
answers
284
views
How to force close terminal window id using AppleScript?
I am starting a new terminal window from a terminal:
osascript -e 'tell app "Terminal" to do script "myProgram.sh"'
Since the new process is not ending(it is basically a server), I ...
0
votes
2
answers
292
views
Defined bash commands not found when passed in "do shell script" in osascript
I am new to shell script and recently wrote a script to open a new terminal window and run defined functions via osascript with "do shell script", but the result showed the command not found....
3
votes
2
answers
2k
views
macOS: How to access the Live Text OCR functionality from AppleScript/JXA?
As of macOS Monterey it is possible to select text in images in Preview.
Is this OCR functionality available from AppleScript and/or JXA (JavaScript for Automation)?
In Script Editor.app File > ...
0
votes
1
answer
135
views
osascript: how to keep nested lists structure when output from command-line
I'm trying to code a script which can be able to extract the menu structure of a given app. This is a simplified working example:
tell application "System Events"
tell process "...
0
votes
0
answers
140
views
How to make a macOS app supports AppleScript ( Displaying Progress )?
I want my macOS app to display a modal progress bar like this:
and want to update the progress by AppleScript.
osascript -l JavaScript -e '
const app = Application("MyApp")
app....
0
votes
1
answer
610
views
Spawn child process, then later send argument to that process
I want to spawn a child process, and then at a later time send an argument to it that will then execute. How can I do that? (NodeJS, on Mac)
For example, I have a command to execute a script file:
...
0
votes
0
answers
260
views
Execute multiple AppleScripts at once
Using macOS's Script Editor I made an application containing the following script. It accepts a plain text URL as an input. It works when I send it one input, let it finish executing the script, then ...
-1
votes
1
answer
660
views
Is there a way to send an iMessage to a group chat using Applescript or any Python module?
I've tried pyimessage, applescript, and osascript. The only thing I could find that seemed promising was this older stackoverflow question:
Send group iMessage using applescript
I wasn't able to get ...
0
votes
3
answers
260
views
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 ...
2
votes
1
answer
408
views
osascript 'do shell script' line endings
I'm trying to debug an larger osascript 'do shell script' program and have narrowed the problem down to a much shorter repro case that I don't understand at all. Here's the repro case:
osascript -e '...
0
votes
2
answers
131
views
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 ...
2
votes
2
answers
411
views
Multiple Applescript lines from terminal osascript call
So I'm trying to run multiple Applescript commands from the command line in one go. However, no matter how I try it, it won't work:
$ osascript -e "set x to 0; display dialog x"
$ osascript -...
0
votes
1
answer
94
views
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 ...
0
votes
0
answers
709
views
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 ...
2
votes
0
answers
462
views
osascript: can't open default scripting component
I run the following nodejs code to execute apple script:
const {exec} = require('child_process')
exec('osascript -e \'return "hello" \'', (err, stdout, stderr)=>{
if (err) return ...
0
votes
1
answer
705
views
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"...
0
votes
1
answer
387
views
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 ...
0
votes
2
answers
842
views
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 ...
0
votes
0
answers
45
views
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 ...
0
votes
3
answers
492
views
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 ...
0
votes
1
answer
401
views
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 ... ...
2
votes
1
answer
349
views
Copy multiple POSIX files to clipboard with applescript
I'm trying to copy multiple files to the clipboard in macos like this:
./file2clip.applescript /User/Cool/Dekstop/test.txt /User/Cool/Dekstop/myfolder
I already can do this with only one file:
#!/usr/...
0
votes
0
answers
54
views
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 ...