I need help learning how to use the AppleScript dictionary for VLC.

This is my first time trying to use an application’s appleScript dictionary.

Seeing some scripts that use the dictionary would help me to begin to understand it.

Any help has my thanks.

DJUNQUERA. I’m sure you know this but AppleScripts do not use the AppleScript dictionary. Instead, people who are writing AppleScripts use the dictionary as a reference.

Just by way of demonstration, say that I want to write a script that prompts the user for an audio file and then plays that audio in QuickTime Player. First, I need to select the audio file. All of the standard dialogs are in the Standard Additions dictionary, so I open that dictionary and search on “choose”. One of the displayed items is “choose file” which shows the following general description plus various options and properties.

Next, I have to load the QuickTime Player and open the audio file. So, I select the QuickTime Player dictionary and the first entry is open, which is defined as:

Finally I want to play the audio and so I search for play and find:

So, my script is as follows. I’ve intentionally omitted some code that normally would be included for the sake of simplicity.

set theAudio to (choose file) as text

tell application "QuickTime Player"
	open file theAudio
	play document 1
end tell

A few other matters of note are:

  • Almost all dictionaries contain a “standard suite” which includes items common to most dictionaries.

  • Some properties contain the notation R/O which indicates that the property can be read but not set.

  • Most commands indicate what is returned. The choose-file command returns an alias, and QuickTime Player’s open command returns a document.

  • The AppleScript dictionaries are not as up-to-date as one would hope, and that’s something to keep in mind.

Anyways, the important point, as noted above, is that the AppleScript dictionaries are reference works only. An additional reference work that I use a lot is the AppleScript Language Guide, the index of which can be found at the following link. It’s informative to compare the information provided for the choose-file command in this guide and in the Standard Additions dictionary.


Hi peavine:

:slight_smile: :slight_smile: :slight_smile: :slight_smile: :slight_smile:

Thank you very much for the time and knowledge you have used to help me.

You have clearly explained concepts that will be very important for me to continue learning.

My knowledge of AppleScript is very limited because I am self-taught and do not know a single word of English (this text that I write to you has been translated by Google Translate).

The only learning material has been the AppleScript Language Guide that you have recommended to me.

I just do simple scripts and continue to learn.

The trigger to try to learn how to use the Application Dictionaries was an elementary script that had the disadvantage of appearing in the front during its execution (something annoying and not very aesthetic).

tell application “VLC” to activate – put the window in front :frowning:
repeat 3 times
tell application “System Events” to key code 125 using {command down}
end repeat

Someone on this forum pointed out to me that the problem was easy to solve using application dictionary commands (volumeDown / volumeUp) and did not have the problem of getting to the front.

tell application “VLC”
end tell

That’s when I decided to start learning how application dictionaries work.

Again thank you very much for your help.
Receive my best wishes for you.

hi DJUNQUERA, how are you? how did you end up using AppleScript manipulating VLC? I am wondering because I am trying to get it open multiple videos at the same time and play them in-sync next to each other, with the instances the volume muted…and loop the videos. Any tips on this? Thank you. Stepan

I’m not sure that you can script all those things in VLC. It does not natively support multiple instances on the mac.

Responding belatedly to the opening post, I’m not sure that VLC is well-suited to learning applescript. While it has a fair number of commands and classes for applescript, I’m not sure how coherent the whole thing is. Documentation, at least within the dictionary, could do with some work.

As to the dual-instances, videolan does offer a page on its wiki on the subject:

VLC HowTo/Play multiple instances

The basic code is as follows:

on run
    do shell script "open -n /Applications/VLC.app"
    tell application "VLC" to activate
end run

on open theFiles
    repeat with theFile in theFiles
        do shell script "open -na /Applications/VLC.app " & quote & (POSIX path of theFile) & quote
    end repeat
    tell application "VLC" to activate
end open

Note that it’s basically just using the shell’s open command with the -n option to open two instances but at that point, there isn’t an integrated way to then control the windows.

Independently, here is a method of moving two existing windows into position.

With the windows already open, it gets each unix id and positions the related window, all using system events. While there are commands to set the play position, the problem, at least for me, is in bridging the launching with the subsequent manipulation. I’m not sure how to derive a means of dealing exclusively with one or the other instance/window from within applescript.

tell application "System Events"
	set uList to unix id of application processes whose name is "VLC"
	--> {24174, 24178} -- unix id or pid
	--> {35283364, 35295655} -- id, of the applescript variety
	set bList to {{0, 23}, {720, 23}} -- positions for windows
	set b to 0
	repeat with a in uList
		set fp to (first process whose unix id = a)
		log fp
		tell (first process whose unix id = a)
			delay 0.1
			set b to b + 1
			set position of window 1 to item b of bList
			set pw to position of window 1
		end tell
	end repeat
end tell