Force timeline redraw

johnmeyer wrote on 11/10/2003, 2:36 PM
I've written an "auditing" script to detect accidental "nudges" of an event's opacity or volume level. I'll post this shortly. I have one problem. When I find an event that has the opacity greater than 90%, but less than 100% (a possible accidental "nudge"), I'd like to move the cursor to this location (easy to do), select the event (also easy to do) and have the timeline show this location.

I can't get the timeline to redraw or refresh. The Vegas.Update() method only redraws the preview window.

Does anyone have a suggestion for a trick to make Vegas redraw the timline?

My fallback plan is to simply ask the user to show the entire timeline prior to running the script, but on big projects, you won't really be able to see which events are being affected.

Comments

jetdv wrote on 11/10/2003, 3:18 PM
Can't be done direct from scripting.
johnmeyer wrote on 11/10/2003, 3:19 PM
Edward,

As always, many thanks.

John
philpw99 wrote on 11/11/2003, 12:52 PM
I had same kind of problem before. All I can do is to post a message and say "this kind of clip was found, press up or download arrow to see it", or " Relax ! this kind of clip was not found."

well, the idea is: when you zoom in or out of a time line, vegas will jump to the cursor immediately.
johnmeyer wrote on 11/11/2003, 1:54 PM
well, the idea is: when you zoom in or out of a time line, vegas will jump to the cursor immediately.

I don't think you can zoom under script control, can you? Remember, I am trying to get the timeline to redraw while staying under script control.
jetdv wrote on 11/11/2003, 3:20 PM
Control of the timeline is not directly controllable via a script - including zoom level or positioning.
SonyPJM wrote on 11/13/2003, 3:10 PM
True.. the scroll position of the timeline can't be changed by a script nor can the zoom... but (just as a small clarification) calling Vegas.UpdateUI() should refresh any visible changes in the timeline as well as the preview window, etc.
johnmeyer wrote on 11/13/2003, 3:25 PM
... but (just as a small clarification) calling Vegas.UpdateUI() should refresh any visible changes in the timeline as well as the preview window, etc.

Unfortunately, this does not happen. For instance, if my script selects and event, or moves the cursor position, if I then call Vegas.UpdateUI(), the preview windows shows the video at the new cursor location (which is how I am able to generate a "preview" within a script), but the timeline does not redraw or change in any way. This is also true if I use SendKeys (not that I recommend doing this as part of a professional script).
jetdv wrote on 11/13/2003, 3:28 PM
Agreed. UpdateUI() will definitely change the preview to show the current cursor location.
SonyPJM wrote on 11/14/2003, 10:24 AM

I believe it will update _visible_ changes in the timeline... if the
change is scrolled out of view, you will not see the update until you
manually scroll there (which can't happen until after the script
completes).
johnmeyer wrote on 11/14/2003, 11:27 AM
SonyPJM,

I don't know why this didn't work before. I just created a test script and, sure enough, the timeline UI does re-draw. Here's the test script that works:


/**
* PURPOSE OF THIS SCRIPT:
*
* Test timeline redraw
*
*
* Written By: John Meyer
* Written: November 14, 2003
*
**/

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


try {

//Global declarations
var trackEnum : Enumerator;
var evnt : TrackEvent;

var track = FindSelectedTrack(); // Use this function to find the first selected track.
var eventEnum = new Enumerator(track.Events);

while (!eventEnum.atEnd()) {
evnt = TrackEvent(eventEnum.item());
evnt.Selected = true; // Select the event
Vegas.Cursor = evnt.Start; // Move cursor to event start
Vegas.UpdateUI();
MessageBox.Show("Do you see another selected event?","Completed",MessageBoxButtons.OK,MessageBoxIcon.Information);
evnt.Selected = false; // De-select the event
eventEnum.moveNext(); // Go to next event on this timeline.
}
}


catch (e) {
MessageBox.Show(e);
}

// End of main program



// Beginning of functions

function FindSelectedTrack() : Track {
trackEnum = new Enumerator(Vegas.Project.Tracks);
while (!trackEnum.atEnd()) {
var track : Track = Track(trackEnum.item());

if (track.Selected) {
return track;
}
trackEnum.moveNext();
}
return null;
}



dust wrote on 11/25/2003, 11:25 PM
Well, one of my big wishes for scripting in a new release... at least the ability to set the preview offset, maybe also length (zoom). together with the ability to access the grouping of events.

The only way out of this problem (that I have as well) is to slightly move the cursor manually a frame to the left or right after the script finished, so the preview jumps onto the cursor position.

SendKey..? Must be a .NET-specific function (I'm not familiar with the whole library)? As far as I know it is not possible to process keyboard presses while a script is running.

But, just an idea... maybe it is possible to deposit keyboard presses by teh script for automatical processing after the script has finished? What I mean is, could a script perform an automatic "push-CursorRight-key" at its end (meaning: after the script has ended, but without needing the user to physically push the button)? This way, the repositioning of the preview window could be done.
johnmeyer wrote on 11/28/2003, 6:07 PM
SendKey..? Must be a .NET-specific function (I'm not familiar with the whole library)? As far as I know it is not possible to process keyboard presses while a script is running.

Sendkeys lets you send keystrokes to the application. This sort of works in Vegas, but I haven't found a way to get Vegas to recognize the keystrokes until the script is finished.

could a script perform an automatic "push-CursorRight-key" at its end (meaning: after the script has ended, but without needing the user to physically push the button)?

The following script will performs an automatic "Ctrl-Alt-Left Arrow" command, thus putting the cursor at the beginning of the event on the selected timeline. I just happened to have this code fragment lying around. It is obviously trivial to modify the one line to feed into Vegas whatever other keystrokes you want.


import System;
import System.IO;
import SonicFoundry.Vegas;
import System.Threading;

try
{
var WshShell = new ActiveXObject("WScript.Shell");
var strDesktop = WshShell.SpecialFolders("Desktop");
WshShell.SendKeys("^%{LEFT}"); // Sends Ctrl-Alt-Left Arrow to Vegas
Vegas.UpdateUI();

// WshShell.Run ("notepad"); // If you un-comment this line, it will start Notepad.

}
catch(e)
{

}
dust wrote on 11/30/2003, 3:09 AM
Hey thanks, works like a charm!!

Guess i should read more about ActiveX :-) I just added this to my scripts, I find that extremely useful! Actually the "var strDesktop = WshShell.SpecialFolders("Desktop");" line isn't even needed.

Maybe this code template should be added to a scripting FAQ..?
johnmeyer wrote on 11/30/2003, 9:42 AM
Q: Could a script perform an automatic "push-CursorRight-key" at its end?

I think you may find that other parts of the script aren't needed as well. This "script" is just a fragment that I used to test out some ideas. I had it lying around and just grabbed it and posted it as a quick answer to your question. As you may have seen, it also shows you how to spawn other applications. Once you understand what is going on, you should be able to do many other things with the Windows calls that you can access. As for putting this into a FAQ, I don't think Sony has a FAQ for any of these forums. I wish they would, especially for the main Vegas forum. Newbies could get their questions answered instantly, and it would be a lot easier to concentrate on the unique questions, problems, and ideas. Hopefully they'll get around to creating a FAQ some day.
dust wrote on 12/7/2003, 6:28 AM
Hmm, I think I found a method to make Vegas perform keystrokes during scripts, or at least a workaround (technically, it is still at its end, but restarts the script afterwards). See http://mediasoftware.sonypictures.com/forums/ShowMessage.asp?ForumID=21&MessageID=234958