AppleScript Navigate through MacOS 13 (Ventura) system preferences? - macos

One new feature of macOS 13 Ventura is the new layout and design of the system preferences. However, this caused many of my automation scripts to stop working.
Does anyone know how to navigate through the new system preferences? To be precise, what is the equivalent to the following code which is compatible with macOS 13 Ventura?
tell application "System Preferences"
activate
set current pane to pane "com.apple.preference.sound"
end tell
The code above worked with old versions fine, but shows
execution error: System Settings got an error: AppleEvent handler
failed. (-10000)
in macOS 13 Ventura

I've encountered the same issue, it seems to be a known issue, and it was also discussed at https://gist.github.com/rmcdongit/f66ff91e0dad78d4d6346a75ded4b751?permalink_comment_id=4286384
What you're looking for is:
do shell script "open x-apple.systempreferences:com.apple.Sound-Settings.extension"
However, manipulating that screen is another pickle.

Does it have to be AppleScript or is bash okay? If bash is an option, you can use the open command. To your specific ask, you can use the following to open Sound preferences:
open x-apple.systempreferences:com.apple.Sound-Settings.extension
More details can be found here: https://www.macosadventures.com/2022/12/05/how-to-open-every-section-of-macos-ventura-system-settings/

Related

How to get current anti-distraction focus in macos with bash?

How to get current focus in macos with bash?
See the article "Help a Mac Automation Find Focus". There is a link to a gist. In the Apple terminal user guide, "Automate tasks using AppleScript and Terminal on Mac" may also help.

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 working and I am no longer able to switch apps using cmd + tab.
I tried restarting the computer, resetting the PRAM, deleting both the com.apple.finder.plist and the com.apple.desktop.plist files, and running a defaults write com.apple.finder CreateDesktop true; killall Finder command. If I run a killall Dock it says they there are no Dock processes running.
The python script I was playing with was just running a simple osascript:
/usr/bin/osascript<<END
tell application "Finder"
set desktop picture to POSIX file "%s"
end tell
Nothing worked. Any ideas on how I could fix this problem? Im on Monterey.
I found a solution. It was hidden in a comment on another similarly related stack overflow question here.
As described by one of the comments, the problem happened after trying to set a malformed image file as my background. I followed the suggested step to delete my ~/Library/Application Support/Dock directory, which solved the problem instantly.

Are m1 macs able to run watch apps?

I have an m1 mac. And I’m trying to create a watch target for my iOS app. After numerous tries, I’ve not been able to run to any watch (either real or simulator).
I also downloaded open source watchOS projects and couldn’t run any of them. I get the error “Could not attach to pid: 18362” “attach failed ((os/kern) invalid argument)
Has anybody faced this challenge? How did they fix it? Is it caused by the m1, cos I was able to create it on another Mac
Found out the hard way.
As of March 2021, the new Mac M1s cannot run WatchKit apps and CarPlay apps. You either end up with the error in the question or another error.
But these errors do not pop up on regular macs.
For building I enable rosetta, otherwise build process fails.
Then if you to launch the build on watch it debugger fails to attach to debugger (same error as above).
Then go and disable Rosetta and then launch watch build once again. It works. Hopefully it helps
Had a similar issue with playground / xcode projects.
When opening the playground the issue appears like this
The Solution for me was to activate the "Rosetta Mode" when having a xcode project and deactivate the "Rosetta Mode" when using the playground.
You can activate / deactivate it by searching for Xcode in your finder (cmd+space, type "Xcode" scroll below and found it) do a right click an click on "Get info" and in the "General" tab you use the "Open using Rosetta" -button.
Maybe this is also a solution for your problem.
Try to uncheck the open with rosetta option for xcode. For me it was working perfectly in my m1 mac book air.

Sandbox is not allowed to open documents in Terminal

Recently I developed an application in Xcode using Swift that starts up the Terminal like this and:
open -a /Application/Utilities/Terminal.app /project/run_stack.sh
After exporting the Application and trying to run it I get this message if my Terminal is running already or I have previously started the same command from the same app (the command is executed through a menu item).
ru_stack.sh can’t be opened because Sandbox is not allowed to open documents in Terminal.
Anyone know why this happens ? If I run it on my Mac it works fine and each time a new terminal starts on the call but when I tried the application on my friend's Mac we get that error in the described cases.
I was having the same problem. I ended up setting iTerm2 as the "Open With" application for .sh files and that fixed my issue. https://iterm2.com/

Applescript to "tell" Spotify to play isn't working after OSX update to Yosemite

Previously to the Yosemite update, I used this Applescript to control my Spotify.
Everything worked as a charm when I ran /usr/bin/osascript /Users/jdrummond/SpotifyControl.scpt play/pause.
Now that I have updated my OSX to Yosemite, I keep getting this when I run the same command:
/Users/jdrummond/SpotifyControl2.scpt:1217:1222: script error: Expected end of line, etc. but found identifier. (-2741)
So I tried to create a simple Applescript to interact with Spotify:
using terms from application "Spotify"
tell application "Spotify" to play
end using terms from
But I'm also getting an error:
What am I doing wrong and how to interact with Spotify on Yosemite? Anything changed?
This issue was reported to Spotify and will be fixed in the next update to the desktop client (I'm a developer there and can verify that it has been fixed).
Currently, the following simple script is working for me on OS X 10.9.5, Spotify 1.0.3.101.gbfa97dfe
tell application "Spotify"
playpause
end tell
I saved it as an app in other to use with my Microsoft Keyboard, so that the play/pause button launches the simple app that plays/pauses.
Spotify destroyed the ability to use AppleScript very recently with their latest idiotic update. It's not Yosemite, it's Spotify.

Resources