HomeHomeSupportSupportFeature Request...Feature Request...Input Card frame captureInput Card frame capture
Previous
 
Next
New Post
12/03/2009 16:04
 

I have written (with help) a really simple frame grabbing application which just takes the input from a capture card, and then saves a frame as a bitmap. I then use ScreenMonkey to replay these images.

What I would really like to do is one of two things. Either automate my clips into ScreenMonkey, or alternatively ScreenMonkey would have the ability to store freeze frames of its input and save them, and of course add them as clips.

I looked at the interaction base class, but that looks as though it's only for controlling the SM app.

Thanks
Andy

 
New Post
12/03/2009 16:38
 

I am not sure whether this is in the release version or the development version but certainly in the development version there is a function in the interaction framework to Add a file or a clip in xml format. I will make you a beta tester so you can download the latest build.

In the ScreenMonkey.Interaction namespce you will find IClipLibrary which contains the function AddFile() which takes a filename. Your plugin will need to inherit from InteractionBase and call GetInterface() on the IInterfaceProvider object that is passed into the Start() function. This will give you a reference to IClipLibrary which you can then use to add and remove clips.

If you get stuck I can post some example code.

Olie

 

 

 
New Post
12/03/2009 17:15
 

Thanks Olie, thats extremely useful!
I found the AddFile() function, but am not sure how to implement it. I would definitely appreciate some example code if possible.

Andy

 
New Post
12/03/2009 20:40
 

No problem, here is the code for an interaction that allows you to connect to Screen Monkey using a TCP terminal and control the program.

I am a little unsure on exactly what you want to achieve, it might be helpful if you could explain in more detail so I can help you more.

/// <summary>

    /// Allows control of Screen Monkey using a TCP terminal.

    /// </summary>

    public class TerminalInteraction:InteractionBase

    {

        IPanelInteraction _panelControl = null;

        IScreenInteraction _screenControl = null;

        IProfileInteraction _profileControl = null;

        IClipLibraryInteraction _libraryControl = null;

 

        private TcpTerminalServer server = new TcpTerminalServer();

 

        /// <summary>

        /// The name of this plugin.

        /// </summary>

        public override string Name

        {

            get { return "Terminal"; }

        }

 

        /// <summary>

        /// A description about what this plugin does.

        /// </summary>

        public override string Description

        {

            get { return "Provides a TCP control terminal on port 3700"; }

        }

 

        /// <summary>

        /// The name used when displaying to the user this plugin.

        /// </summary>

        public override string Caption

        {

            get { return "TCP Terminal"; }

        }

 

        /// <summary>

        /// Who created the plugin.

        /// </summary>

        public override string Author

        {

            get { return "Oliver Waits"; }

        }

 

        /// <summary>

        /// A string to represent the version of the plugin.

        /// </summary>

        public override string Version

        {

            get { return "1.0"; }

        }

 

        /// <summary>

        /// Starts the interaction plugin and initialises the interactions.

        /// This is called when Screen Monkey first starts and an interface provider

        /// is passed in which you can use to query usful interfaces to perform functions

        /// within Screen Monkey.

        /// </summary>

        /// <param name="interfaceProvider">The Screen Monkey interface provider. </param>

        public override void Start(IInterfaceProvider interfaceProvider)

        {

            base.Start(interfaceProvider);

 

            //Get the Panel interface to do things like change clip page.

            _panelControl = (IPanelInteraction)_interfaceProvider.GetInterface(typeof(IPanelInteraction));

 

            //Get the screen interface to play clips.

            _screenControl = (IScreenInteraction)_interfaceProvider.GetInterface(typeof(IScreenInteraction));

 

            //Get the profile interface to change the display profile.

            _profileControl = (IProfileInteraction)_interfaceProvider.GetInterface(typeof(IProfileInteraction));

 

            //Get the library interface to add and remove clips.

            _libraryControl = (IClipLibraryInteraction)_interfaceProvider.GetInterface(typeof(IClipLibraryInteraction));

 

            //Open a TCP terminal server that accepts text commands. Compatible with terminals such as PUTTY.

            server.TerminalCommand += new EventHandler<TerminalCommandEventArgs>(server_TerminalCommand);     

 

            server.Port = 3700;

            server.Start();

        }

 

        /// <summary>

        /// Called when Screen Monkey is closing and should be used to perform any cleanup operations.

        /// </summary>

        public override void Stop()

        {

            base.Stop();

 

            //Stops the terminal server and closes any ports.

            server.Stop();

        }

 

        /// <summary>

        /// Called when a new command is recieved over the TCP terminal.

        /// </summary>

        /// <param name="sender"></param>

        /// <param name="e"></param>

        void server_TerminalCommand(object sender, TerminalCommandEventArgs e)

        {

            TerminalRootOptions rootOptions = new TerminalRootOptions();

            TerminalOptions subOption = null;

 

            if (ProcessCommand(e.Client, rootOptions, e.Command, true))

            {

                if (rootOptions.Play) subOption = new PlayOptions();

                else if(rootOptions.Clear) subOption = new ClearOptions();

                else if (rootOptions.Layer>0) subOption = new LayerOptions();

                else if (rootOptions.Clip) subOption = new ClipOptions();

                else if (rootOptions.Pause) _screenControl.Pause();

                else if (rootOptions.Go) _screenControl.Go();

 

                if (subOption != null)

                {

                    if (ProcessCommand(e.Client, subOption, e.Command, false))

                    {

                        if (subOption is PlayOptions) ProcessPlay((PlayOptions) subOption);

                        if (subOption is ClearOptions) ProcessClear((ClearOptions) subOption);

                        if (subOption is LayerOptions) ProcessLayer((LayerOptions)subOption);

                        if (subOption is ClipOptions) ProcessClip((ClipOptions)subOption);

                    }

                }

 

            }

           

        }

       

        /// <summary>

        /// Plays a clip in Screen Monkey.

        /// </summary>

        /// <param name="options">Information about which clip to play.</param>

        private void ProcessPlay(PlayOptions options)

        {

            //Does the command specify a clip id or handle index.

            if(options.Id)

                //Play the clip by clip id.

                _screenControl.PlayClip(options.Clip);

            else

                //Play the clip by handle index. This is the index of the clip on a page.

                _panelControl.PlayClip(options.Clip - 1);

        }

 

        /// <summary>

        /// Clears the screen

        /// </summary>

        /// <param name="options">Not Used</param>

        private void ProcessClear(ClearOptions options)

        {

            //Clears the screen and stops all clips.

            _screenControl.ClearScreen();

        }

 

        /// <summary>

        /// Adds or removes clips from the library.

        /// </summary>

        /// <param name="options"></param>

        private void ProcessClip(ClipOptions options)

        {

            if (options.Add)

            {

                if (options.Filename != "")

                {

                    _libraryControl.AddFile(options.Filename);

                }

            }

            _screenControl.ClearScreen();

        }

 

        /// <summary>

        /// Changes the opacity of a layer.

        /// </summary>

        /// <param name="options"></param>

        private void ProcessLayer(LayerOptions options)

        {

            if (options.Layer>0 && options.Layer <= _profileControl.ActiveProfile.Layers.Count)

            {

                if(options.Transparency>=0) _profileControl.ActiveProfile.Layers[options.Layer-1].Opacity = (float)options.Transparency / 100;

            }           

        }

 

        /// <summary>

        /// Called when a new command ocurrs.

        /// </summary>

        /// <param name="client"></param>

        /// <param name="options"></param>

        /// <param name="command"></param>

        /// <param name="ignoreErrors"></param>

        /// <returns></returns>

        private bool ProcessCommand(TcpTerminalClient client, TerminalOptions options, string command, bool ignoreErrors)

        {

            CommandLineParser parser = new CommandLineParser(options);

 

            parser.Parse(command, false);

 

            if (options.ShowHelp())

            {

                client.Send(parser.UsageInfo.GetHeaderAsString(78));

                client.Send(parser.UsageInfo.GetOptionsAsString(78));

                return false;

            }

            else if (parser.HasErrors)

            {

                if (ignoreErrors) return true;

 

                client.Send(parser.UsageInfo.GetErrorsAsString(78));

                return true;

            }

 

            return true;

        }

 

        /// <summary>

        /// Saves any settings for this plugin. The settings should be written to the Xml writer.

        /// </summary>

        /// <param name="writer"></param>

        public override void SaveSettings(System.Xml.XmlWriter writer)

        {

        }

 

        /// <summary>

        /// Loads any setting which have been saved for this plugin.

        /// </summary>

        /// <param name="settings"></param>

        public override void LoadSettings(System.Xml.XmlNode settings)

        {

        }

    }

 

 
New Post
13/03/2009 09:00
 

The code looks good! I am still struggling to use it as I'm unsure which ScreenMonkey dll's to reference from my project. I haven't given up though!

My main purpose of this post is to explain what I'm trying to achieve.
Using my application, I want to be able to store a bitmap from a video capture card, and then add this bitmap as a clip to ScreenMonkey automatically, rather than having to go into ScreenMonkey and selecting the file. Should be easy!!

Let me know what you think...
Andy

 
Previous
 
Next
HomeHomeSupportSupportFeature Request...Feature Request...Input Card frame captureInput Card frame capture


Copyright 2010 by Oliver Waits