Writing scripts for Fast video cataloger

Writing scripts for Fast video cataloger

Fast video cataloger supports scripting in C#. You write script straight into he scripts window and run them by clicking run. If you want to be efficient it pays to spend a few minutes and setup a proper development environment.

Environment

Fast video cataloger has a text editor but it is really not great for writing code. It has no syntax highlighting and there is no help with the APIs. I highly recommend that you download visual studio from Microsoft, and download the real visual studio not the code version.

Downlloado visual studio

With Visual Studio, you will get a proper editor that knows C# and will provide syntax coloring. We have also created a Visual Studio project with all the samples. This solution let you compile all the samples to catch simple syntax errors right in the environment. The solution produces an output file but that one is of no practical use so ignore that artifact. The only use of the visual studio solution is as a help for writing scripts.

Another benefit of using the provided solution is that you will get full IntelliSense to help with the scripting API as well as with any other .net library you might want to use. Add your own script to the solution and develop them there.

The documentation

When you install Fast video cataloger there are two documentations installed. The normal program documentation and scripting documentation in the form of a “scripting.chm” in the install folder. The scripting documentation details the whole scripting API and what you can do. Scripting in Fast video cataloger is focused on the actual catalog and not the user interface. You can make a lot of changes directly to the catalog but for the user interface to reflect the changes you need to explicitly call the Refresh() function from the script to force the user interface to reload from the state of the catalog.

There are also higher-level user interface functions in the program that are not exposed to scripting. For example, the repair functions can not be scripted. It is possible to write your own repair function using the API but we have not exposed the high-level user interface. Scripting by clicking menus and buttons in the interface should be possible using ui automation tools but that is the type of native scripting we talk about here.

The samples

When you install fast video cataloger a number of sample scripts are also installed in the Scripts/Samples folders. They are documented in the scripting documentation and the visual studio solution loads them all so it is easy to look at the code.

Writing your own scripts

When starting writing your own scripts I highly recommend starting with one of the supplied scripts. Find the script that is most close to what you want to do. Make a copy of that script. Add it to the sample solution and change the class name to something suitable. Build the solution to ensure it compiles and continue from there.

How to run scripts

Scripts are run from the script window as mentioned before. When you run a script you can also provide a string as an argument. Use this as a way to customize your script without having to edit the actual script. You load a script by clicking the “Load” button. If you are working with the script in visual studio you can reload the same script from the same file by holding Shift when clicking the Load button. That way you don’t need to pick the same file every time you need to reload the script as you are developing it in visual studio. (Selecting run in Visual studio will not work as we are not compiling a program and there is no way for Fast video cataloger to know you have clicked F5 and that one of your scripts is loaded in the program)

Setting up an action button for a script

Once you have a script you are happy about and expect to use often as part of your workflow it is time to bind an action to it. Actions are created from the preference dialog.

Action to run a script.

An Action will create a button in the Action window, in the “Custom Action” area and you can run your script just by clicking that button.

If clicking the button does not work there is probably something wrong with your script. Remember that the script is run and error messages are printed in the console window.

Setting a shortcut to a script

If you have a script you really use a lot it is possible to first create an Action and then bind a shortcut to that Action from the Shortcut window.

References

Most of the samples provided use the same resources as the standard .net library, these references are included by default and you only need to add a “using” line at the top of your script. If you want to use references that are not available by default you will need to add a comment starting with “//css_ref” followed by the reference you want. So for example //css_ref PresentationCore; references the Presentation core.



//css_ref WindowsBase;
//css_ref PresentationCore;
//css_ref PresentationFramework;
//css_ref System.Runtime
//css_ref System.ObjectModel

This is similar to a C# application where you would add a reference in the visual studio solution. To work with the sample solution you would need to include the reference in the solution to get it to compile and the //cs_ref line to get it running inside Fast video cataloger.

WPF and XAML resources

Since Fast video cataloger is running scripts and compiling the c# file when the script is loaded it won’t work with compiled XAML files. It is still possible to use WPF but you will need to load the XAML file dynamically.

If you have not done so already, download Fast video cataloger and try to write some scripts.