You are not logged in.
Pages:: 1
I made a script to launch and then play/pause Spotify:
Applescript:
tell application "System Events"
tell application "Spotify" to activate
delay 0.2
key code 49 --spacebar
delay 0.2
set visible of process "Spotify" to false
delay 0.2
end tell
When I run the script in Script Editor, it works fine. However, when I launch it (I use BetterTouchTools), it just launches Spotify, and then nothing happens.
_______
Also, to avoid creating another thread...
I'm trying to do the same thing for skipping songs—to open Spotify, press the next button, and then hide the app—but this doesn't work at all.
This is my script:
Applescript:
tell application "System Events"
tell application "Spotify" to activate
delay 0.3
click at {689.48, 750.57}
delay 0.3
set visible of process "Spotify" to false
delay 0.3
end tell
What am I doing incorrectly?
Offline
1) Your first script replace with this:
Applescript:
tell application "Spotify" to playpause
2) Your second script replace with this:
Applescript:
tell application "Spotify" to next track
Last edited by KniazidisR (2020-11-30 05:42:16 am)
Model: MacBook Pro
OS X: Catalina 10.15.4
Web Browser: Safari 13.1
Ram: 4 GB
Offline
[...]
Those are much better. Thanks. However, the scripts work fine in the Script Editor, but when I try to launch them (with BetterTouchTools), nothing happens.
I think there is a setting preventing scripts from working correctly.
(Even though I've added BetterTouchTool and Spotify to Accessibility in "Security & Privacy.")
What do I need to make sure is set up for scripts to work?
Last edited by KevS (2020-11-30 07:43:17 am)
Offline
KevS. I don't use BTT and instead use a somewhat similar utility called Fastscripts. To get it to work with GUI scripting in Catalina, I did the following in Security & Privacy:
* add Fastscripts to Accessibility
* add Fastscripts to Full Disk Access
* add System Events (which is found in /System/Library/CoreServices/) to Full Disk Access
I'm not sure if this will work but it's easy to try and is easily undone. Perhaps someone who uses BTT will be able to better help.
Last edited by peavine (2020-12-01 02:27:26 pm)
2018 Mac mini - macOS Catalina
Offline
I was able to launch the scripts using another app (they all work now). The first time I ran them, an OS window appeared asking to allow it to control System Events, and it was added to "Automation" in "Security & Privacy."
There doesn't seem to be any "+" button or any other way to add apps, so that I can add BetterTouchTool, though...
Offline
I don't know why you are so stuck with GUI scripting solution. In my opinion, it would be better if you in Security & Privacy would grant your application permission to control not System Events, but Spotify.
Last edited by KniazidisR (2020-12-01 02:02:20 pm)
Model: MacBook Pro
OS X: Catalina 10.15.4
Web Browser: Safari 13.1
Ram: 4 GB
Offline
I don't know why you are so stuck with GUI scripting solution. In my opinion, it would be better if you in Security & Privacy would grant your application permission to control not System Events, but Spotify.
I'll try to re-organize the settings to make it work.
Thanks for help, KniazidisR.
Offline
Pages:: 1