How to use Clipboard.SetText and Clipboard.GetText with Calgo?

Created at 23 Apr 2013, 10:58
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
AD

adrian

Joined 27.09.2012

How to use Clipboard.SetText and Clipboard.GetText with Calgo?
23 Apr 2013, 10:58


This example is working perfectly out of Calgo:

using System;
using System.Windows.Forms;
 
class Program {
    [STAThread]
    static void Main(string[] args) {
         Clipboard.SetText("this is in clipboard now");
    }
}

However, in Calgo, no matter where i put  [STAThread] i'm getting errors.

How to make this working?

thanks

 


@adrian
Replies

atrader
23 Apr 2013, 16:24

This should work:

Locate System.Windows.Forms.dll in your system and add a reference to it in cAlgo.

for instance if you have framework 4.0 installed:

//#reference: C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Windows.Forms.dll

using System;
using cAlgo.API;

using System.Windows.Forms;
using System.Threading;

namespace cAlgo.Robots
{

    [Robot]
    public class NewRobot : Robot
    {

        protected override void OnStart()
        {
            copy_to_clipboard();
        }

        public void somethingToRunInThread()
        {
            Clipboard.SetText("this is in clipboard now");
} protected void copy_to_clipboard() { Thread clipboardThread = new Thread(somethingToRunInThread); clipboardThread.SetApartmentState(ApartmentState.STA); clipboardThread.Start(); } } }




@atrader

prihod007
06 May 2024, 12:11

RE: How to use Clipboard.SetText and Clipboard.GetText with Calgo?

atrader said: 

This should work:

Locate System.Windows.Forms.dll in your system and add a reference to it in cAlgo.

for instance if you have framework 4.0 installed:

//#reference: C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Windows.Forms.dll using System; using cAlgo.API; using System.Windows.Forms; using System.Threading; namespace cAlgo.Robots {    [Robot]    public class NewRobot : Robot    {        protected override void OnStart()        {            copy_to_clipboard();        }        public void somethingToRunInThread()        {            Clipboard.SetText("this is in clipboard now");
        }        protected void copy_to_clipboard()        {            Thread clipboardThread = new Thread(somethingToRunInThread);            clipboardThread.SetApartmentState(ApartmentState.STA);                        clipboardThread.Start();        }    } }



 

can you tell me if it is possible to do something like this in MAC OS?


@prihod007