Ejemplo n.º 1
0
        public SlaveController(Port portForRegistrationToRouter, ModuleType moduleType, message_based_communication.encoding.Encoding customEncoding, string nameOfApplicationToControl) : base(portForRegistrationToRouter, moduleType, customEncoding)
        {
            PythonStarter.StartPythonMouseControlApi();
            PythonStarter.StartPythonKeyboardControlApi();

            Thread.Sleep(10); // the mouse control api must be running before the mouseActionHandler can be instanciated

            // FIRST USE THE GetWindowByWindowTitle and GetClassName - when you know the class name, switch to GetWindowByClass
            Console.WriteLine("Getting window handle");
            appWindow = WindowUtils.GetWindowHandle(windowTitleText: new Regex(nameOfApplicationToControl));
            Console.WriteLine("Got window handle");

            var pyAutoGuiForMouseControl = new PythonWrapper(new Port()
            {
                ThePort = 60606
            });                                                                           //TODO FIX, not sure what I mean here anymore

            this.mouseActionHandler = new MouseActionHandler(pyAutoGuiForMouseControl, appWindow);

            var pyAutoGuiForKeyboardControl = new PythonWrapper(new Port()
            {
                ThePort = 60600
            });

            this.keyboardActionHandler = new KeyboardActionHandler(pyAutoGuiForKeyboardControl);

            WindowUtils.PutWindowOnTop(appWindow);

            PythonStarter.StartPythonScreenCapture(appWindow);


            //ensure that a folder is created to store files from the fileserver
            filesDirectory = Directory.CreateDirectory(Directory.GetCurrentDirectory() + Path.DirectorySeparatorChar + "ccfeu-files");
            //make sure the filesDirectory is empty;
            EmptyDirectory(filesDirectory);
            IsRunning = true;
        }