Hi all --
Following advice from Andy (dust), I tried using the SendKeys method to get the Vegas UI to respond to a couple of arrow keys, so the cursor would scroll to be visible. However, that was ineffective in my case because my script opens a Windows.Forms Form which had focus at the time; the arrow keys were sent to the Form which ignored them, and they never reached Vegas.
Here is the code I came up with to send the key strokes to Vegas when my form has the focus:
Just after an event handler that updated Vegas.Cursor, I had:
// 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 = Vegas.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);
Following advice from Andy (dust), I tried using the SendKeys method to get the Vegas UI to respond to a couple of arrow keys, so the cursor would scroll to be visible. However, that was ineffective in my case because my script opens a Windows.Forms Form which had focus at the time; the arrow keys were sent to the Form which ignored them, and they never reached Vegas.
Here is the code I came up with to send the key strokes to Vegas when my form has the focus:
Just after an event handler that updated Vegas.Cursor, I had:
// 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 = Vegas.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);