PDA

View Full Version : How-To: Autoselect VTEdit script



John Perkins
04-13-2005, 07:26 PM
Here's an example of using callbacks, mouse actions and the switcher. It's written for the total noobie and should help get someone off to a decent start on quite a few subjects.

The result is a script that will put whatever VT Edit window you are using onto Main In so that you can see it on the monitor. If the switcher is open, it will act normally.

I did this because I tend to use multiple VT Edit windows. Sometimes the CG or capture will kick VTEdit off of main in too. You get really tired of manually placing your windows onto main in so this speeds up the workflow a lot.

Place this in:

C:\VT4\Skins\VideoEditor\MainWindow\Main\User Scripts

so that our script will only effect VT Edit windows.

Call it autoselect.ToasterScript
Any name will work, but it should end in .ToasterScript


// Autoselect this module onto Main In when the Switcher is inactive

AddCallback(MouseEnter, code(
if(!IsPluginRunning("Switcher_Tabbed"))
PlaceOntoMainIn() )
)




The first line:
// Autoselect this module onto Main In when the Switcher is inactive

is called a comment. Anything after // will be ignored by ToasterScript.

Be nice and let people know what the script does. Scripts can get complicated and what makes perfect sense to you now may not a year from now.


AddCallback() tells this module that from now on, it will pay attention for some action to take place. This can be a mouse action, a timer, GPI trigger or any number of things. You can find this in section 2.4 of the ToasterScript2 docs.

In this case we are looking for the mouse to be within the VTEdit window.

AddCallback(MouseEnter, code() )

Whatever you want to happen will be placed within the () after the word code.

The next line is a little more complicated, but easy once you know how to read it.

if(something is true) do something

That is the basic format. The ! means to negate, or if(something is NOT true)

We don't want to do this and ruin someones live switch, so we check to see if the switcher (called Switcher_Tabbed in module speak) is open and only do our trick if the switcher is !open.

if(!IsPluginRunning("Switcher_Tabbed"))

Now we need to take action and place our VT Edit onto the main input. This could have been on the same line as the if statement, but it is much easier to read this way.

PlaceOntoMainIn() )

Notice that ) hanging out at the end? It is the closing parenthesis that goes with the code () we used earlier. Everything we just did from if through PlaceOntoMainIn took place in the code section.

The last thing left is to put one more )
at the end to close up our AddCallback(). If you ever forget to close one of these, your script will fail to run because it doesn't know where that command stops.

Now open VT4, open a couple of VTEdit windows and place different clips in each one. Run the mouse over them and it will magicly be placed onto the monitor.


I hope this helps someone and if you have anything to add or find errors, let me know.

John Perkins
04-13-2005, 08:00 PM
Already seeing inprovements...


// Autoselect this module onto Main In when the Switcher is inactive

AddCallback(MouseEnter, code(
if(!((IsPluginRunning("Switcher_Tabbed"))|
(IsPluginRunning("RecordPanel"))|
(IsPluginRunning("LiveStreamDlg"))|
(IsPluginRunning("VideoEditor_BatchCapture"))
))
PlaceOntoMainIn() )
)

As I was writing, I realized that there were other modules that needed constant focus on Main In.

The | between the lines means OR as in "this OR that OR this other thing".

Also notice that I wrapped all the OR options in one set of parenthesis. This makes the !(not) sign effect all of them.

Now try to follow those parenthesis...