MacOS command line tool which executes OSA scripts (AppleScript, JavaScript, etc.)
Questions tagged [osascript]
267 questions
1
vote
1 answer
How to open new Terminal tab and get focus back to the prev tab?
I want to run a command in a terminal tab which will open a new tab, run a command there too and then get the focus back to the previous Terminal tab (the one i run the first command), is it possible?
using of corse osascript.
what i have so…

Alex Rabinovich
- 35
- 6
1
vote
1 answer
Concurrent execution of script in different tab windows
I'm trying clone down git repo's concurrently in different Mac terminal tabs as they take a long time to clone down.
I've tried a lot of variations of the below but can't seem to get each separate clone and then following commands in 3 separate…

JL9
- 533
- 3
- 17
1
vote
1 answer
Send iMessage to group chat
How can you send a iMessage to a group chat? I have searched everywhere and I can't find anything. I want to send it to a group chat named something, possibly If I get a list of buddies in the chat I can send it to everyone at once? A problem may be…

user7903682
- 199
- 1
- 1
- 18
1
vote
1 answer
Can't send message to group chat
I found a script that sends messages from the command line, but It won't work with my group chat with spacing and capitalization in the name.
#!/bin/sh
recipient="${1}"
message="${*:2}"
echo "$recipient"
cat<

user7903682
- 199
- 1
- 1
- 18
1
vote
1 answer
Swift + Xcode: use osascript in Mac App
I want to ask if you can use osascript in swift/xcode when designing a Mac (Sierra) app. So I've basically just built an empty app using Xcode and swift.
I would now like to use osascript to launch another app using osascript (preferred).
So I've…

enigma
- 11
- 2
1
vote
2 answers
Shell script for closing all apps open dock via command line
I'd like to run a script to close all apps currently open in my doc. Figured out how to do with with the following script, where APPLICATIONNAME is the name of the app in the dock currently open
osascript -e 'quit app "APPLICATIONNAME"'
Any ideas on…

Nick Sarafa
- 986
- 10
- 16
1
vote
1 answer
AppleScript to remove icon from dock
I need to be able to run the script through Terminal only. I've seen other scripts that work as long as you change some settings in Accessibility; this is not an option for what I'm trying to do. I've tried the script below, but receive the…

pineapple_tree
- 11
- 3
1
vote
1 answer
Cancel button on osascript in a bash script
i have a small Problem with a osascrip line in a bash script.
The bash script gets called via a Applescript 'choose from list' dialogue, and then you can define options via a if [[ $* = *"Option 1... selection tag.
A friend gave me the osascript…

devilhunter
- 321
- 1
- 4
- 13
1
vote
0 answers
How to set volume on OSX at login prompt?
I want to do the same thing as osascript set volume isn't working via ssh, except that no user is logged (sshd is launched at startup without login).

Labo
- 2,482
- 2
- 18
- 38
1
vote
1 answer
Get PIDs of all open windows on MacOS
I tried to use the following AppleScript to get the PIDs of all the windows (including ones that are minimized). This script doesn't get the PIDs of windows on other desktops.
Is there any workaround for this so I can still get a list of opened…

Alok Mysore
- 606
- 3
- 16
1
vote
1 answer
Applescript keystroke capitalises some characters
127 ;-(Tue Jan 03 22:27:09 Mac mini ~
$ echo 'tell application "System Events" to keystroke "Changeme@123"'|osascript
CHAN
0 :-)Tue Jan 03 22:27:17 Mac mini ~
$ CHANgeme@123
$ zsh
Mac mini% echo 'tell application "System Events" to…

Iceman
- 365
- 1
- 3
- 13
1
vote
2 answers
custom icon in dialog
I have a file in my current directory Icon.png.
How do I make this the icon for an applescript dialog?
I have tried
$ osascript -e 'display dialog "Hey" with icon file "./Icon.png"'
0:54: execution error: File file ./Icon.png wasn’t found. (-43)
So…

theonlygusti
- 11,032
- 11
- 64
- 119
1
vote
1 answer
Python script does not work when started via osascript
Ok, so when I run this command:
sudo python3.5 /path/to/my/script.py
It executes fine and returns:
select user:
Guest
My username
Choose the account that needs cleaning up (enter corresponding number):
After which I enter "2", press enter and…

Montmons
- 1,416
- 13
- 44
1
vote
1 answer
Applescript: iTerm to split pane from the window the script was called
I have the following script with attempts to split the window vertically, and tail a log file in the new pane.
#!/bin/bash
COMMAND="tail -f log_file"
# Do something important.
sleep 4
# Split the window, and tail logs.
osascript <<-EOF
tell…

John Bupit
- 10,406
- 8
- 39
- 75
1
vote
0 answers
Spotify ::: playing songs using osascript and Python
I am running a python script in order to play two Spotify songs in a row via Echonest api.
Apparently, there's something wrong with this osacript syntax:
def play(id1, id2):
print 'playing', id1, 'then', id2
os.system("osascript -e 'tell…

8-Bit Borges
- 9,643
- 29
- 101
- 198