Hello,
I have been trying to create a window using following code.
using System; using System.Collections.Generic; using System.Diagnostics; using System.Drawing; using System.Runtime.InteropServices; using System.Windows.Forms; using ScriptPortal.Vegas; public class EntryPoint { public Form prompt; public Vegas myveg; public Button mybut; public void FromVegas(Vegas vegas) { myveg = vegas; prompt = new Form { Width = 300, Height = 150, Text = "Keyframer", BackColor = Color.Red }; mybut = new Button { Text = "Add a value", Left = 0, Width = 123, Height = 64, BackColor = Color.White }; mybut.Click += BtnKick; prompt.Controls.Add(mybut); prompt.ShowDialog(); } private void BtnKick(object sender, EventArgs e) { var tracks = myveg.Project.Tracks; foreach (var ev in tracks) { if (ev.MediaType == MediaType.Video) { foreach (var effect in ev.Effects) { if (effect.Bypass) { continue; } try { if (!effect.IsOFX) { continue; } } catch (COMException) { continue; } var ofx = effect.OFXEffect; foreach (var parameter in ofx.Parameters) { if (parameter is OFXDoubleParameter) { var p = parameter as OFXDoubleParameter; p.SetValueAtTime(Timecode.FromFrames(30), 69); } } } } } } }
Sadly, this window cannot be use while working in Vegas, as it's a modal dialog, and i need to switch between Vegas and this window..
When i changed it ShowDialog to Show, the Vegas crashed while execution..
Exception 0xE0434352 (Unknown Type) IP:0x00007FFB34154ED9 In Module 'KERNELBASE.dll' at Address 0x00007FFB34120000 + 0x0000000000034ED9
Interestingly when i removed the following line, it didn't crash..
p.SetValueAtTime(Timecode.FromFrames(30), 69);
I found out that Vegas doesn't crash when i access a value, like p.Keyframes.Count, but when i change a value, it does..
I tried to add the following code after the prompt.Show line, and then it didn't crash, but i couldn't still access Vegas while running..
while (!prompt.IsDisposed) { Application.DoEvents(); }
That could mean, that Vegas have problem with modifying a value after the script finishes, but i have no clue why..
I am using Vegas Pro 17, which is not the currently newest version, but i think the scripting along this subject didn't changed since then..
Can someone help me with this ?
I would also appreciate to know if there are other ways to create windows that can be used simultaneously while working in Vegas, or point to a publicly accessible script / library that uses one..