From d3e4e53c1b0391df2b35701b7ad81513a30a347d Mon Sep 17 00:00:00 2001 From: "Valeriano A.R" Date: Fri, 1 Nov 2019 02:37:36 +0100 Subject: [PATCH] FrmScreenAutomation: Process bots always. --- .../FrmScreenAutomation.Designer.cs | 1 + VAR.ScreenAutomation/FrmScreenAutomation.cs | 19 +++++++++++++++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/VAR.ScreenAutomation/FrmScreenAutomation.Designer.cs b/VAR.ScreenAutomation/FrmScreenAutomation.Designer.cs index ed22c2d..62c443f 100644 --- a/VAR.ScreenAutomation/FrmScreenAutomation.Designer.cs +++ b/VAR.ScreenAutomation/FrmScreenAutomation.Designer.cs @@ -109,6 +109,7 @@ this.ddlAutomationBot.Name = "ddlAutomationBot"; this.ddlAutomationBot.Size = new System.Drawing.Size(293, 24); this.ddlAutomationBot.TabIndex = 4; + this.ddlAutomationBot.SelectedIndexChanged += new System.EventHandler(this.DdlAutomationBot_SelectedIndexChanged); // // btnStartEnd // diff --git a/VAR.ScreenAutomation/FrmScreenAutomation.cs b/VAR.ScreenAutomation/FrmScreenAutomation.cs index 7520253..6156ae8 100644 --- a/VAR.ScreenAutomation/FrmScreenAutomation.cs +++ b/VAR.ScreenAutomation/FrmScreenAutomation.cs @@ -33,6 +33,8 @@ namespace VAR.ScreenAutomation ddlAutomationBot.Items.AddRange(AutomationBotFactory.GetAllAutomationBots()); ddlAutomationBot.SelectedIndex = 0; + _automationBot = AutomationBotFactory.CreateFromName((string)ddlAutomationBot.SelectedItem); + _automationBot?.Init(ctrOutput); if (components == null) { components = new Container(); } @@ -53,13 +55,16 @@ namespace VAR.ScreenAutomation bmpScreen = Screenshoter.CaptureControl(picCapturer, bmpScreen); - if (_automationBot != null && _running) + if (_automationBot != null) { bmpScreen = _automationBot.Process(bmpScreen, ctrOutput); - string responseKeys = _automationBot.ResponseKeys(); - if (string.IsNullOrEmpty(responseKeys) == false && WindowHandling.ApplicationIsActivated() == false) + if (_running) { - SendKeys.Send(responseKeys); + string responseKeys = _automationBot.ResponseKeys(); + if (string.IsNullOrEmpty(responseKeys) == false && WindowHandling.ApplicationIsActivated() == false) + { + SendKeys.Send(responseKeys); + } } } picPreview.ImageShow = bmpScreen; @@ -97,5 +102,11 @@ namespace VAR.ScreenAutomation _running = false; btnStartEnd.Text = "Start"; } + + private void DdlAutomationBot_SelectedIndexChanged(object sender, EventArgs e) + { + _automationBot = AutomationBotFactory.CreateFromName((string)ddlAutomationBot.SelectedItem); + _automationBot?.Init(ctrOutput); + } } }