Lock/Unlock Tracks Script?

i am erikd wrote on 4/22/2014, 9:41 AM
I loved using this script for years from Edward Troxel but I can't get it work in either V12 or V13. Does anyone have this script working in either V12 or V13?

I still can't understand why Vegas doesn't have a simple button for locking a track on each track. Why make us right click/select events to end or whatever?




tim-evans wrote on 4/22/2014, 11:09 AM
I have not upgraded to 13 yet.. Works fine in version 12. Agree with comment on SCS giving us the ability. It would be so easy to do that it would appear to be a deliberate decision on their part. My first NLE Pinnacle Studio could do it ....what?.... all of 16 years ago

I would like the locked tracks to stand out a little more visually.
VideoFreq wrote on 4/22/2014, 1:48 PM
I agree. In fact not only Pinnacle has this but also Power Director. Locking a track though, usually causes problems. I would like to see them include a scroll bar on the left side of the timeline bc when you have a two monitor setup, its a bit of a hassle.
Geoff_Wood wrote on 4/22/2014, 3:54 PM
Check out V13 - all your desires (not quite) fulfilled, sans-Script , with the convenient button on the transport control strip ?

Like me, you would like a button on the track header (or at least r-click option) to completely lock everything on that track.

What did the script do ?

i am erikd wrote on 4/23/2014, 12:14 AM
The script would simply lock/unlock the tracks selected when running the script. Simple but yet needed. This is a .js script that I put in the Vegas script menu folder but Vegas does not see it in V12 or V13.

jetdv wrote on 4/23/2014, 9:30 AM
Actually, the script will lock/unlock all EVENTS on selected tracks.

As you said, it's a simple .js script so I'm not sure why it would not appear in Vegas Pro 12 or 13 as long as it's placed in the Vegas Pro 12/13 "Script Menu" folder. There's nothing complicated about the script to prevent it from working. Here's the script:


* This script will lock all events on selected tracks
* Written By: Edward Troxel
* Copyright 2006 - JETDV Scripts
* Modified: 07-20-2006

import System;
import System.IO;
import System.Windows.Forms;
import Sony.Vegas;

try {
var dolock = true; //Change to FALSE to unlock

//Go through the list of Tracks
var trackEnum = new Enumerator(Vegas.Project.Tracks);
while (!trackEnum.atEnd()) {
var track : Track = Track(trackEnum.item());

if (track.Selected) {
//Go through the list of Events
var eventEnum = new Enumerator(track.Events);
while (!eventEnum.atEnd()) {
var evnt : TrackEvent = TrackEvent(eventEnum.item());

if (dolock) {
evnt.Locked = true;
} else {
evnt.Locked = false;


} catch (e) {

It could certainly be easily updated to a .cs script and should probably be updated to ask if you prefer to lock or unlock the selected tracks.
i am erikd wrote on 4/23/2014, 10:05 AM
Thanks Edward.

I have verified that the scripts are in the Script Menu folder for V12 and V13 and I don't see them still. But I should have pointed out that I don't see any of the .cs or .js scripts. V11 does work. Weird.

Has anyone got this working in V12 or hopefully V13?

jetdv wrote on 4/23/2014, 12:28 PM
It appears to be showing fine in VP13:


I placed it in

c:\Program Files\Sony\Vegas Pro 13.0\Script Menu
i am erikd wrote on 4/24/2014, 3:33 AM
Yes same as me and thanks for the pic. Now I've got to figure out why on my system none of my scripts in the folder show in V13. Seems very odd.

Thanks again,

ushere wrote on 4/24/2014, 4:11 AM
hi edward,

just tried it and got this error message:

C:\Program Files\Sony\Vegas Pro 13.0\Script Menu\LockSelectedTracks.js(1) : Syntax error. Write 'var identifier : Type' rather than 'Type identifier' to declare a typed variable

and how do you unlock tracks?

ah. just read, change to 'false' ;-)
jetdv wrote on 4/24/2014, 9:48 AM
Please make sure you copy the whole thing beginning with /** and ending with the last }

It sounds like you started copying after the "Try" line.
NormanPCN wrote on 4/24/2014, 9:52 AM
RE: Syntax error

When you copied Edwards script the words "code block" should not be in the script file.

Ignore everything above the first comment which is the line with "/**"