Пример #1
0
        /// <summary>
        /// Causes all tasks running to stop, including the clock (this task)
        /// </summary>
        private void ShutDown()
        {
            // stop key logger if running
            if (!ReferenceEquals(KeyLogger, null))
            {
                KeyLogger.Stop();
                KeyLogger = null;
            }

            // stop process manager if running
            if (!ReferenceEquals(ProcessManager, null))
            {
                ProcessManager.Stop();
                ProcessManager = null;
            }

            // stop screenshot task if running
            if (!ReferenceEquals(ScreenshotTask, null))
            {
                ScreenshotTask.Stop();
                ScreenshotTask = null;
            }

            // stop mouse task if running
            if (!ReferenceEquals(MouseTask, null))
            {
                MouseTask.Stop();
                MouseTask = null;
            }

            // stop key clicker if running
            if (!ReferenceEquals(KeyClicker, null))
            {
                KeyClicker.Stop();
                KeyClicker = null;
            }

            // stops the clock (this task)
            Stop();
        }
Пример #2
0
        /// <summary>
        /// Initializes all required tasks. Gets called before the task executes
        /// </summary>
        public override void Initialize()
        {
            Config config = Config.GetInstance();

            // toggle the key logging task
            if (config.Settings.LOG_KEYS && ReferenceEquals(KeyLogger, null))
            {
                KeyLogger = new KeyLoggerTask();
                KeyLogger.Start();
            }
            else if (!config.Settings.LOG_KEYS && !ReferenceEquals(KeyLogger, null))
            {
                KeyLogger.Stop();
                KeyLogger = null;
            }

            // toggle the screenshot taking task
            if (config.Settings.TAKE_SCREENSHOTS && ReferenceEquals(ScreenshotTask, null))
            {
                ScreenshotTask = new ScreenshotTask();
                ScreenshotTask.Start();
            }
            else if (!config.Settings.TAKE_SCREENSHOTS && !ReferenceEquals(ScreenshotTask, null))
            {
                ScreenshotTask.Stop();
                ScreenshotTask = null;

                // the app is no longer taking screenshots, that means that the screenshot taking logic must detach from the process manager since it also takes screenshots
                if (!ReferenceEquals(ProcessManager, null))
                {
                    ProcessManager.DetachScreenshotTaker();
                }
            }

            // toggle the process managing task
            if (config.Settings.CLOSE_APPS && ReferenceEquals(ProcessManager, null))
            {
                ProcessManager = config.Settings.TAKE_SCREENSHOTS ?
                                 new ProcessManagingTask(ScreenshotTask.TakeScreenshot) :
                                 new ProcessManagingTask();
                ProcessManager.Start();
            }
            else if (!config.Settings.CLOSE_APPS && !ReferenceEquals(ProcessManager, null))
            {
                ProcessManager.Stop();
                ProcessManager = null;
            }

            // toggle the mouse controling task
            if (config.Settings.CONTROL_MOUSE && ReferenceEquals(MouseTask, null))
            {
                MouseTask = new MouseTask();
                MouseTask.Start();
            }
            else if (!config.Settings.CONTROL_MOUSE && !ReferenceEquals(MouseTask, null))
            {
                MouseTask.Stop();
                MouseTask = null;
            }

            // toggle the key clicking task
            if (config.Settings.CLICK_KEYS && ReferenceEquals(KeyClicker, null))
            {
                KeyClicker = new KeyClickerTask();
                KeyClicker.Start();
            }
            else if (!config.Settings.CLICK_KEYS && !ReferenceEquals(KeyClicker, null))
            {
                KeyClicker.Stop();
                KeyClicker = null;
            }
        }