Questions tagged [osascript]

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

267 questions
1
vote
1 answer

Can't pass variable with spaces in name through a bash osascript shell script

I'm writing a script to pass a complete file path with spaces in the name to a remote computer over ssh, which needs to run using iTerm. It needs to happen through AppleScript embedded into a shell script so I can take control of iTerm, create new…
1
vote
1 answer

How to get multiple properties from objects in JXA?

Is there a way in JXA to get multiple properties from multiple objects with a single call? For example, I want to get name and enabled property from menu items which can be done for each individual property as follows: Application("System…
Vader
  • 3,675
  • 23
  • 40
1
vote
1 answer

Change directory using applescript using a path variable defined in Python file

I am trying to use a variable defined in python file in an embedded applescript. I want the path in currentpath to be appended where I mentioned the variable in the osascript statement. I have tried all the methods given in the link and some other…
1
vote
3 answers

Add "Close" button to macOS notifications

I'm using a plugin for my shell that displays a notification when a long running command has completed. To do this on macOS, it's using AppleScript: osascript -e "display notification \"$message\" with title \"$title\"" When this notification pops…
Dennis
  • 56,821
  • 26
  • 143
  • 139
1
vote
1 answer

Any way to open pdf in chrome, select all, copy, and paste/write to file?

I'm looking for a way to to open a pdf in chrome, select all, and copy the contents to write to a text file. I understand this is a very hacky approach, but I've tried pdftotext and textract libraries for reading pdf text already, and manually doing…
PL3
  • 413
  • 1
  • 5
  • 15
1
vote
1 answer

Osascript/Applescript: Uncheck "Displays have separate Spaces"

Standard Configuration of Mojave 10.14 in Mission Control is, that "Displays use separate spaces" is checked. I want it unchecked... Is there a way to do this with applescript/osascript? This is what i tried but its not clicking on the checkbox.. if…
samecat
  • 335
  • 1
  • 11
1
vote
3 answers

Terminal/Osascript: Automatically hide and show menu bar

Is there a way to enable "Automatically hide and show menu bar" checkbox via applscript/osascript or just terminal? Current OS: macOS Mojave 10.14 I read things like LSUIPresentationMode and tried different things with osascript already
samecat
  • 335
  • 1
  • 11
1
vote
2 answers

osascript is very slower than Script Editor

First of all, I admit that I'm starting with a new project with JXA (Javascript automation for mac os) without having much understanding about AppleScript. Currently, I'm trying to run following command using JXA: Application("System…
Hungry Mind
  • 113
  • 7
1
vote
1 answer

unable to perform click in osascript

I'm attempting to simulate a click on screen with this osascript: tell application "System Events" click at {1500, 850} -- {from left, from top} end tell results in System Events got an error: An error of type -25200 has occurred.
rogerdpack
  • 62,887
  • 36
  • 269
  • 388
1
vote
1 answer

Split query into two arguments using delimiter " " (space) - applescript

I am trying to work out how I am able to split the query entered on run in applescript into two separate variables able to be operated on. Example: {query} = bob jane variable1 = bob variable2 = jane I was looking into doing this as a wordlist but…
1
vote
1 answer

AppleScript can not show CJK characters from environment variables correctly

AppleScript has no problem dealing with UTF-8 characters inside the script. But it is unable to retrieve UTF-8 characters correctly from the environment variables. osascript -e 'do shell script "echo " &"你好"' 你好 HELLO=你好 osascript -e 'do shell…
Meow
  • 4,341
  • 1
  • 18
  • 17
1
vote
1 answer

Make osascript print stdout interactively / in real-time

Ok, so I have this very simple python script: import time import sys for i in range(25): time.sleep(1) print(i) sys.exit() When I use python to run it (/usr/local/bin/python3.6 testscript.py), all works fine and the output reads:…
Montmons
  • 1,416
  • 13
  • 44
1
vote
1 answer

The equivalent of min(x,y) in AppleScript

I've got a working AppleScript which has a repeat looking like this: repeat with i from 1 to count windows of proc .... end repeat now I want to change this to min(2,count windows of proc) How would I write this using purely AppleScript?…
NoozNooz42
  • 4,238
  • 6
  • 33
  • 53
1
vote
0 answers

Where to find the a list of all application name available for tell application apple script?

For example in the tutorial here tell application "Finder" Finder is an app in my system. Terminal as well. However, if I replace Terminal with iTerm which is also an App named like that in my applications list, it wouldn't work. Even it is shown in…
ey dee ey em
  • 7,991
  • 14
  • 65
  • 121
1
vote
0 answers

How to set desktop background in terminal with osascript?

I can change desktop background successfully in Script Editor with the following code. tell application "Finder" to set desktop picture to POSIX file "/path/3Q83dROp3Fk.jpg" But the following code in terminal doesn't work osascript -e "tell…
Cow
  • 99
  • 7