FrmScreenAutomation: Process bots always.

This commit is contained in:
2019-11-01 02:37:36 +01:00
parent 437366fd67
commit d3e4e53c1b
2 changed files with 16 additions and 4 deletions

View File

@@ -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
//

View File

@@ -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);
}
}
}