How to Clear VLC Playlist with Apple Scripts - macos

By default, VLC will keep the songs that were played in the last session as part of the playlist. I have an AppleScript that plays music that is stored as MP3 files in a folder.
tell application "VLC"
set thePlaylist to "file:////Users/[username]/Music/Playlist"
OpenURL thePlaylist
end tell
Since VLC stores the last songs, it will start playing from wherever the song was last and then play from this playlist afterwards.
I've tried a couple of commands, but I haven't been able to clear the playlist from my AppleScript.

Short answer: you can't do this through AppleScript. VLC's scripting dictionary is only a list of verbs — actions that can be performed on the current playing item — it has no nouns or object references that would let you specify things like 'playlists', 'videos', 'tracks', etc. There is no way to 'talk' to VLC about anything other than the currently queued item.
That might be something to report to VLC's developer. It's a weak AppleScript dictionary.
You might be able to fix this in VLC's Preferences. Looking at the full settings in VLC (click the "Show All" button at the bottom left) the two I highlighted seem like the might give you some control. There might be other setting that I didn't see; you should look through the options.

Related

MacOS: Determine which monitor any window application is on?

I'm currently attempting to have my system pipe audio to a specific output depending on which monitor that application is running on. For instance, if a web browser is playing videos on monitor A, sound comes out of output 1. If it is on monitor B, it comes out of output 2. Is there any way to poll which monitor any/all applications are located/active on macOS?
The question hasn't given many details, but in principle you can recover the position of the window using code like the:
tell application "System Events"
tell process "App Name"
set windowPos to position of first window
end tell
end tell
... and then compare that to the frame of each desktop to discover which display the window is in. If you need to determine the frame of each desktop programmatically (instead of hand-coding them in), that will take some extra work: either digging the values out of a system plist file or using AppleScriptObjC to get the frame dimensions from NSScreen. Let me know if you need that, and I'll update when I get a chance.

How to start a slideshow without music in applescript?

Currently I am using this applescript to start a slideshow:
set theAlbumName to "Test"
tell application "Photos"
start slideshow using media items of album theAlbumName
end tell
However, no matter what I do, there is always music when the slide show starts.
There are videos in my slide show and I do not want music playing over them.
Is there any way to NOT have music, or change the music to something different (an empty sound file?) when you call it from the applescript?
I have tried deleting the project's music, but when I call the slideshow from applescript, there is still music.
Thanks in advance.

How do you assign a keyboard shortcut or hotkey in sketchbook pro?

I'm using Sketchbook pro for mac, the documentation that states: "Many of the tools found in the lagoon and menus have assigned hotkeys. You can also check out the Preferences window for a list of them or to remap a tool." However, the link they provide does not give information about how to remap commands.
So trying to switch gears and use hotkeys instead, now the documentation describes a method of assigned hotkeys; however, this doesn't work and nothing happens. Also mysteriously the documentation shows the lagoon with the ability for hotkeys however on my desktop this isn't what I see (see figure below)
Ultimately my goal is to assign commands to my tablet, literally I just want to assign the r key to the rectangle tool instead of the ruler as shown. The problem is that on my Wacom I can only use keystrokes and as it is there is no keystroke for the rectangle command, so frustrating.
It seems like it would be so simple to just "assign keyboard shortcuts in sketchbook pro" but I can't find a single example of it actually happening, I only find references to it being possible, like for example the end of this video see image below:
I don't mind trying to figure out how to use Applescript but I can't find any information on how to talk to sketchbook with applescript. Frustratingly there is an interface to run Applescripts...but no information about how to write applescript to interact with sketchbook commands, see figure:
I'm not sure about applescript, so I hope someone else can help.
You cannot set your own shortcuts inside of SketchBook.
You can only select from the list provided.
In your screen-cap the context of that video is setting your Wacom tablet buttons to Sketchbook hotkeys. That end slide is attempting to communicate that you can use our suggestions (which are listed in the video) or make your own configuration from the available hotkey list. It's not meant to say that you can create your own custom hotkeys.
What are you using the rectangle so much for? 🤔
Regarding AppleScript, I've checked via Autodesk Support and they replied they currently do not support it.
The fact that you see your script appearing in "Sketchbook Pro > Services" is a MacOS feature, it doesn't necessary mean Sketchbook knows about it.

OSX Photos video play/pause Applescript shortcut

There is currently no keyboard shortcut to play videos in the new Mac Photos application.https://discussions.apple.com/thread/6996731?start=0&tstart=0
Rather than be frustrated in manually clicking the "play" button hundreds of times, I would like to run an Applescript to play/pause with a keyboard shortcut. I tried with no success:
tell application "photos"
"play" video
end tell
Any help advice on this would be appreciated.
Thanks
Just to update Paul's response, in Photos 2.0 (3150.4.120), you need to hit TAB twice, then spacebar will start playback. Similarly you need to hit TAB twice once you are done playing it, and then (and only then) spacebar will take you back to the grid view of your thumbnails.
If you do not mind a slightly time-consuming workaround, you can enslave Automator to create a Service that will subsequently respond to a keyboard shortcut. You can find the instructions here.
Since your goal is to use the keyboard, there's a better option for you. After selecting a video with cursor keys or mouse, press space to maximize the video, and then press TAB. Then space will start the video playing, left and right arrows will move frame-by-frame. Hitting TAB again will allow the space bar to return the video to its normal size.
Apparently this changes the focus to the pane with the movie so that space can start it, or perhaps it changes focus to the movie controls? IMHO, whatever it does, it's not very intuitive and badly needs to documented and preferably fixed.
More info at:
https://discussions.apple.com/thread/6996731?start=0&
2020 / Photos 6.0:
You can now toggle playback with Option + Space
or do it manually via "Image" -> "Start Playback".
Autoplay Script
repeat while application "Photos" is running
delay 1
try
tell application "System Events"
tell process "Photos"
click menu item "Start Playback" of menu "Image" of menu bar 1
end tell
end tell
end try
end repeat
Save it as autoplay.scpt and run it with osascript autoplay.scpt.
The script exits when you close the Photos application.

AppleScript event listening

I'm wanting to make a AppleScript to give me the current track name playing on itunes. So far I have made it get the name and refresh after the song has played with duration of the song.
Delay Song_duration
What I'm getting a problem is if the user skips the song manually or changes the song; I can see the are events called "next track" and "previous track" but it seems you can't do stuff like:
if (next track) then
because it does the event in the brackets. What I'm wanting to know is if there is a way to listen for the event. I don't know much about AppleScript, just been looking online for answers.
The general gist of the script is I want to get the name of the track and artist instantly with as little CPU/Memory as possible or I would just do delay 1.
Basically you can't do it with applescript.
iTunes sends out a system wide notification whenever it's state changes called "com.apple.itunes.playerInfo". So you need to write in a language that can receive system notifications, objective-c for example. In that language you register for system notifications under the NSDistributedNotificationCenter. Once registered your program would run in the background, using little to no system resources, and then whenever something changes in iTunes your program would receive a notification and then you do something with iTunes.
Here's a link to a similar question and a couple solutions are posted.

Resources