Project Filename, "DoEvents" after SendKeys

Vegas - The Big Gamble wrote on 8/14/2005, 7:30 PM
Two questions in one here.. just to see if I can solve them in one go! Any solutions much appreciated:

1) Am I right in thinking the API can't tell me the project's filename? I'd have thought it would be logical to want to know the current name - in one case I have a script which generates an HTML page with a table showing plug-ins in use within in a project, but I can't head the table automatically with the project filename)

2) I have used WshShell.SendKeys (yuck!) to get round a problem of accessing an un-implemented feature but i find it doesn't seem to process the instructions until after completing the rest of the script. Is there any type of "DoEvents" or "wait" that can be done here?

Otherwise I could try a "Wscript.Sleep" but I'm not sure that this is a reliable way to resolve the issue.

Thanks in advance

drew

Comments

jetdv wrote on 8/14/2005, 8:39 PM
1) Am I right in thinking the API can't tell me the project's filename?

No, you are wrong. This is the current project filename:
Vegas.Project.FilePath

If it returns null, the file has not been saved.


2) Is there any type of "DoEvents" or "wait" that can be done here?

No. Vegas will not process anything until the script is finished.
johnmeyer wrote on 8/14/2005, 9:24 PM
This code snippet may be helpful:
  var eventEnum = new Enumerator(track.Events);
while (!eventEnum.atEnd()) {
evnt = TrackEvent(eventEnum.item());
var MyFilePath = evnt.ActiveTake.MediaPath;
var extFileName = Path.GetFileName(MyFilePath);
var baseFileName = Path.GetFileNameWithoutExtension(extFileName); // Media file name for this event


As for the SendKeys, here are some code fragments I found from other people's scripts:
// Vegas interface does not allow to scroll the timeline display. Activate the Vegas
// app and send the Up-arrow and Down-arrow keystrokes to ensure cursor is visible.
// Figure out the appName -- in my version of Vegas, it is "project.veg - Sony Vegas 5.0" or
// "project.veg * - Sony Vegas 5.0" (if project has been modified)
var projectName : String = this.m_Project.FilePath;
projectName = projectName.substring(projectName.lastIndexOf("\\") + 1);
var appName : String = projectName + " - Sony Vegas 5.0";

var wshShell = new ActiveXObject("WScript.Shell");
var activateWasSuccessful : Boolean = wshShell.AppActivate(appName);
if (! activateWasSuccessful) {
appName = projectName + " * - Sony Vegas 5.0";
wshShell.AppActivate(appName);
}
System.Threading.Thread.Sleep(100); // puts current thread to sleep for 100 milliseconds
SendKeys.SendWait("{Up}");
SendKeys.SendWait("{Down}");
wshShell.AppActivate(this.FindForm().Text);
}


I have no idea whether this code works.
Vegas - The Big Gamble wrote on 8/16/2005, 3:29 AM
That's all very useful to know!!

Thanks very much for the responses....

I had no idea that "Vegas.Project.FilePath" would return the filename itself since "FilePath" always used to mean the path and *not* the filename when I was a lad!!!

I'll post further developments in this thread
jetdv wrote on 8/16/2005, 6:26 AM
Yeah, it includes both the full path AND the file name.