MacOS command line tool which executes OSA scripts (AppleScript, JavaScript, etc.)
Questions tagged [osascript]
267 questions
0
votes
2 answers
How to generate osascript with if else condition that could be ran as NSAppleScript
I am trying to launch an application and open a file in it through applescript. I was able to do it from the Apple Script Editor. This is th escript i wrote:
set AppPath to ""
tell application AppPath
if it is running then
…

sajas
- 1,599
- 1
- 17
- 39
0
votes
2 answers
How to use AppleScript to switch Caps Lock Key to be Ctrl Key
I can't seem to figure out how to select the correct buttons with Applescript. I am starting to learn vim and want to be able to toggle the Caps Lock Key between Caps Lock and Ctrl. I have marked the steps which I need to complete.
I found (this…

Alex Cory
- 10,635
- 10
- 52
- 62
0
votes
0 answers
Automator shell script - warn if mv is a duplicate
I've built an Automator application that takes a file and (after an admin password is entered) changes the ownership and moves it to another user's folder. I'm using the command:
mv -i source target
to move the file. The -i option will prompt…

Adam
- 613
- 7
- 16
0
votes
2 answers
Cannot get osascript to open multiple terminal tabs at locations I want them to
I am trying to write a script which will two tabs on a terminal. I want each tab to tail a different logfile. The script is located in a /scripts directory and the logs are located in the parent directory.
The first tab and tail works fine. The…

Breako Breako
- 6,353
- 14
- 40
- 59
0
votes
1 answer
Osascript keycodes for arrow keys
I'm trying to call osascript in Python to simulate key presses with something like this:
cmd = """
osascript -e 'tell application "System Events" to keystroke "e"'
"""
os.system(cmd)
How can I send key presses for the up/down/left/right…

user2827595
- 31
- 1
0
votes
2 answers
Get Finder Selection directly in Java without any help of Applescript
Is it possible to get the Finde-Selection directly in Java without any help of Applescipt? Basically its possible by executing an osascript in Java which calls another applescript that passes the Finder-selection as a string. thx.
import…

domizai
- 343
- 1
- 5
- 13
0
votes
2 answers
Can I manipulate the location of a dialog displayed through osascript?
I've been playing around with various UNIX commands and came across this one to display a dialog:
osascript -e 'tell app "System Events" to display dialog "Hello World"'
I'd like to change the position of the dialog. For most commands, I can just…

MacBoss123541
- 198
- 1
- 17
0
votes
0 answers
Executing AppleScript with PHP shell_exec() and OSAScript
My goal is to be able to submit a search query from a web form and have an AppleScript execute the search in DEVONagent. The AppleScript works fine in terminal but I get an error when having PHP do a shell_exec().

Justin
- 43
- 5
0
votes
3 answers
PHP exec and OSASCRIPT?
I have a little Apple script as follow:
beep
delay 2
tell application "Finder" to activate
It just makes a sound, wait 2 second and then bring the "Finder" window to the foreground.
When I run it from the command line, it works fine.
Then I want…

MikaelW
- 1,145
- 4
- 11
- 29
0
votes
1 answer
How to distinct multiple java processes in AppleScript
I encounter a problem when writting osascript. I need to "tell" one java process (GUI) to do something but there are other java process with the same process name "java" (also GUI),
so my below sample code will not work for me:
osascript \
-e…

Daniel
- 3
- 2
0
votes
1 answer
Call osascript through php shell_exec doesn't work
I was trying some things with osascript when I had this problem.
Here is my test :
/usr/bin/osascript <<-EOF
tell application "System Events"
activate
display dialog "Hello world"
end tell
EOF
Here is my PHP file.…

Matthieu Riegler
- 31,918
- 20
- 95
- 134
0
votes
1 answer
PHP not properly executing bash script
I am creating a simple web page that will allow the user to select an option on a basic php page, click submit, and then the backend PHP should execute a bash script, that will execute some AppleScript.
I can run the bash script from Terminal and…

MZimmerman6
- 8,445
- 10
- 40
- 70
0
votes
1 answer
osascript and python gives error (-2741)
Thanks for taking the time to read this. I am calling up a osascript inside of a python script on Mac OS X 10.7.
osascript -e 'tell application "Microsoft PowerPoint" to activate' -e 'tell application "System Events" to key code 124'
Here is the…

Jason S.
- 13
- 1
- 5
0
votes
0 answers
Why does this preinstall script just partly run?
I use PackageMaker to create an installation package. The following is my preinstall script to be called by Installer:
#!/bin/sh
/usr/bin/osascript <

Niamh Doyle
- 1,909
- 7
- 30
- 42
-1
votes
1 answer
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.

Santanu Karar
- 1,034
- 1
- 12
- 27