Initial commit
This commit is contained in:
4
.gitignore
vendored
Normal file
4
.gitignore
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
/.vs/
|
||||
**/bin/**
|
||||
**/obj/**
|
||||
*.user
|
||||
25
VAR.ScreenAutomation.sln
Normal file
25
VAR.ScreenAutomation.sln
Normal file
@@ -0,0 +1,25 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.29418.71
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VAR.ScreenAutomation", "VAR.ScreenAutomation\VAR.ScreenAutomation.csproj", "{E2BE8E2A-3422-42A6-82FA-5E0CCDC42032}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{E2BE8E2A-3422-42A6-82FA-5E0CCDC42032}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{E2BE8E2A-3422-42A6-82FA-5E0CCDC42032}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{E2BE8E2A-3422-42A6-82FA-5E0CCDC42032}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{E2BE8E2A-3422-42A6-82FA-5E0CCDC42032}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {8DEFE02E-819D-4286-8378-BE842DBBBFC4}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
6
VAR.ScreenAutomation/App.config
Normal file
6
VAR.ScreenAutomation/App.config
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
|
||||
</startup>
|
||||
</configuration>
|
||||
28
VAR.ScreenAutomation/Bots/DummyBot.cs
Normal file
28
VAR.ScreenAutomation/Bots/DummyBot.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using System.Drawing;
|
||||
using VAR.ScreenAutomation.Interfaces;
|
||||
|
||||
namespace VAR.ScreenAutomation.Bots
|
||||
{
|
||||
public class DummyBot : IAutomationBot
|
||||
{
|
||||
private int frameCount = 0;
|
||||
|
||||
public void Init(IOutputHandler output)
|
||||
{
|
||||
frameCount = 0;
|
||||
output.Clean();
|
||||
}
|
||||
|
||||
public Bitmap Process(Bitmap bmpInput, IOutputHandler output)
|
||||
{
|
||||
frameCount++;
|
||||
output.AddLine(string.Format("Frame: {0}", frameCount));
|
||||
return bmpInput;
|
||||
}
|
||||
|
||||
public string ResponseKeys()
|
||||
{
|
||||
return "{UP}";
|
||||
}
|
||||
}
|
||||
}
|
||||
169
VAR.ScreenAutomation/Code/Mouse.cs
Normal file
169
VAR.ScreenAutomation/Code/Mouse.cs
Normal file
@@ -0,0 +1,169 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace VAR.ScreenAutomation.Code
|
||||
{
|
||||
public class Mouse
|
||||
{
|
||||
public enum MouseButtons
|
||||
{
|
||||
Left,
|
||||
Middle,
|
||||
Right
|
||||
}
|
||||
|
||||
public static void SetButton(MouseButtons button, bool down)
|
||||
{
|
||||
INPUT input = new INPUT
|
||||
{
|
||||
Type = INPUT_MOUSE
|
||||
};
|
||||
input.Data.Mouse.X = 0;
|
||||
input.Data.Mouse.Y = 0;
|
||||
if (button == MouseButtons.Left)
|
||||
{
|
||||
input.Data.Mouse.Flags = down ? MOUSEEVENTF_LEFTDOWN : MOUSEEVENTF_LEFTUP;
|
||||
}
|
||||
if (button == MouseButtons.Middle)
|
||||
{
|
||||
input.Data.Mouse.Flags = down ? MOUSEEVENTF_MIDDLEDOWN : MOUSEEVENTF_MIDDLEUP;
|
||||
}
|
||||
if (button == MouseButtons.Right)
|
||||
{
|
||||
input.Data.Mouse.Flags = down ? MOUSEEVENTF_RIGHTDOWN : MOUSEEVENTF_RIGHTUP;
|
||||
}
|
||||
INPUT[] inputs = new INPUT[] { input };
|
||||
if (SendInput(1, inputs, Marshal.SizeOf(typeof(INPUT))) == 0)
|
||||
throw new Exception();
|
||||
}
|
||||
|
||||
public static void Click(MouseButtons button)
|
||||
{
|
||||
SetButton(button, true);
|
||||
System.Threading.Thread.Sleep(500);
|
||||
SetButton(button, false);
|
||||
}
|
||||
|
||||
public static void GetPosition(out UInt32 x, out UInt32 y)
|
||||
{
|
||||
GetCursorPos(out POINT lpPoint);
|
||||
x = lpPoint.X;
|
||||
y = lpPoint.Y;
|
||||
}
|
||||
|
||||
public static void SetPosition(UInt32 x, UInt32 y)
|
||||
{
|
||||
SetCursorPos(x, y);
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct INPUT
|
||||
{
|
||||
public uint Type;
|
||||
public MOUSEKEYBDHARDWAREINPUT Data;
|
||||
}
|
||||
|
||||
public const int INPUT_MOUSE = 0;
|
||||
public const int INPUT_KEYBOARD = 1;
|
||||
public const int INPUT_HARDWARE = 2;
|
||||
|
||||
/// <summary>
|
||||
/// http://social.msdn.microsoft.com/Forums/en/csharplanguage/thread/f0e82d6e-4999-4d22-b3d3-32b25f61fb2a
|
||||
/// </summary>
|
||||
[StructLayout(LayoutKind.Explicit)]
|
||||
public struct MOUSEKEYBDHARDWAREINPUT
|
||||
{
|
||||
[FieldOffset(0)]
|
||||
public HARDWAREINPUT Hardware;
|
||||
|
||||
[FieldOffset(0)]
|
||||
public KEYBDINPUT Keyboard;
|
||||
|
||||
[FieldOffset(0)]
|
||||
public MOUSEINPUT Mouse;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// http://msdn.microsoft.com/en-us/library/windows/desktop/ms646310(v=vs.85).aspx
|
||||
/// </summary>
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct HARDWAREINPUT
|
||||
{
|
||||
public uint Msg;
|
||||
public ushort ParamL;
|
||||
public ushort ParamH;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// http://msdn.microsoft.com/en-us/library/windows/desktop/ms646310(v=vs.85).aspx
|
||||
/// </summary>
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct KEYBDINPUT
|
||||
{
|
||||
public ushort Vk;
|
||||
public ushort Scan;
|
||||
public uint Flags;
|
||||
public uint Time;
|
||||
public IntPtr ExtraInfo;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// http://social.msdn.microsoft.com/forums/en-US/netfxbcl/thread/2abc6be8-c593-4686-93d2-89785232dacd
|
||||
/// https://msdn.microsoft.com/es-es/library/windows/desktop/ms646273%28v=vs.85%29.aspx
|
||||
/// </summary>
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct MOUSEINPUT
|
||||
{
|
||||
public int X;
|
||||
public int Y;
|
||||
public uint MouseData;
|
||||
public uint Flags;
|
||||
public uint Time;
|
||||
public IntPtr ExtraInfo;
|
||||
}
|
||||
|
||||
public const int MOUSEEVENTD_XBUTTON1 = 0x0001;
|
||||
public const int MOUSEEVENTD_XBUTTON2 = 0x0002;
|
||||
|
||||
public const uint MOUSEEVENTF_ABSOLUTE = 0x8000;
|
||||
public const uint MOUSEEVENTF_HWHEEL = 0x01000;
|
||||
public const uint MOUSEEVENTF_MOVE = 0x0001;
|
||||
public const uint MOUSEEVENTF_MOVE_NOCOALESCE = 0x2000;
|
||||
public const uint MOUSEEVENTF_LEFTDOWN = 0x0002;
|
||||
public const uint MOUSEEVENTF_LEFTUP = 0x0004;
|
||||
public const uint MOUSEEVENTF_RIGHTDOWN = 0x0008;
|
||||
public const uint MOUSEEVENTF_RIGHTUP = 0x0010;
|
||||
public const uint MOUSEEVENTF_MIDDLEDOWN = 0x0020;
|
||||
public const uint MOUSEEVENTF_MIDDLEUP = 0x0040;
|
||||
public const uint MOUSEEVENTF_VIRTUALDESK = 0x4000;
|
||||
public const uint MOUSEEVENTF_WHEEL = 0x0800;
|
||||
public const uint MOUSEEVENTF_XDOWN = 0x0080;
|
||||
public const uint MOUSEEVENTF_XUP = 0x0100;
|
||||
|
||||
[DllImport("User32.dll")]
|
||||
public static extern int SendInput(int nInputs, INPUT[] pInputs, int cbSize);
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Struct representing a point.
|
||||
/// </summary>
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct POINT
|
||||
{
|
||||
public UInt32 X;
|
||||
public UInt32 Y;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the cursor's position, in screen coordinates.
|
||||
/// </summary>
|
||||
/// <see>See MSDN documentation for further information.</see>
|
||||
[DllImport("user32.dll")]
|
||||
public static extern bool GetCursorPos(out POINT lpPoint);
|
||||
|
||||
[DllImport("User32.dll")]
|
||||
public static extern Boolean SetCursorPos(UInt32 X, UInt32 Y);
|
||||
|
||||
}
|
||||
}
|
||||
40
VAR.ScreenAutomation/Code/Screenshoter.cs
Normal file
40
VAR.ScreenAutomation/Code/Screenshoter.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace VAR.ScreenAutomation.Code
|
||||
{
|
||||
public class Screenshoter
|
||||
{
|
||||
public static Bitmap CaptureControl(Control ctrl, Bitmap bmp = null)
|
||||
{
|
||||
if (ctrl == null) { return bmp; }
|
||||
Point picCapturerOrigin = ctrl.PointToScreen(new Point(0, 0));
|
||||
bmp = CaptureScreen(bmp, picCapturerOrigin.X, picCapturerOrigin.Y, ctrl.Width, ctrl.Height);
|
||||
return bmp;
|
||||
}
|
||||
|
||||
public static Bitmap CaptureScreen(Bitmap bmp = null, int? left = null, int? top = null, int? width = null, int? height = null)
|
||||
{
|
||||
if (width <= 0 || height <= 0) { return bmp; }
|
||||
|
||||
// Determine the size of the "virtual screen", which includes all monitors.
|
||||
left = left ?? SystemInformation.VirtualScreen.Left;
|
||||
top = top ?? SystemInformation.VirtualScreen.Top;
|
||||
width = width ?? SystemInformation.VirtualScreen.Width;
|
||||
height = height ?? SystemInformation.VirtualScreen.Height;
|
||||
|
||||
// Create a bitmap of the appropriate size to receive the screenshot.
|
||||
if (bmp == null || bmp?.Width != width || bmp?.Height != height)
|
||||
{
|
||||
bmp = new Bitmap(width ?? 0, height ?? 0);
|
||||
}
|
||||
|
||||
// Draw the screenshot into our bitmap.
|
||||
using (Graphics g = Graphics.FromImage(bmp))
|
||||
{
|
||||
g.CopyFromScreen(left ?? 0, top ?? 0, 0, 0, bmp.Size);
|
||||
}
|
||||
return bmp;
|
||||
}
|
||||
}
|
||||
}
|
||||
43
VAR.ScreenAutomation/Code/WindowHandling.cs
Normal file
43
VAR.ScreenAutomation/Code/WindowHandling.cs
Normal file
@@ -0,0 +1,43 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace VAR.ScreenAutomation.Code
|
||||
{
|
||||
public class WindowHandling
|
||||
{
|
||||
private static readonly IntPtr HWND_TOPMOST = new IntPtr(-1);
|
||||
private const UInt32 SWP_NOSIZE = 0x0001;
|
||||
private const UInt32 SWP_NOMOVE = 0x0002;
|
||||
private const UInt32 TOPMOST_FLAGS = SWP_NOMOVE | SWP_NOSIZE;
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
private static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, uint uFlags);
|
||||
|
||||
public static void WindowSetTopLevel(Form form)
|
||||
{
|
||||
SetWindowPos(form.Handle, HWND_TOPMOST, 0, 0, 0, 0, TOPMOST_FLAGS);
|
||||
}
|
||||
|
||||
public static bool ApplicationIsActivated()
|
||||
{
|
||||
var activatedHandle = GetForegroundWindow();
|
||||
if (activatedHandle == IntPtr.Zero)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var procId = Process.GetCurrentProcess().Id;
|
||||
GetWindowThreadProcessId(activatedHandle, out int activeProcId);
|
||||
return activeProcId == procId;
|
||||
}
|
||||
|
||||
[DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
|
||||
private static extern IntPtr GetForegroundWindow();
|
||||
|
||||
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
|
||||
private static extern int GetWindowThreadProcessId(IntPtr handle, out int processId);
|
||||
}
|
||||
}
|
||||
115
VAR.ScreenAutomation/Controls/CtrImageViewer.cs
Normal file
115
VAR.ScreenAutomation/Controls/CtrImageViewer.cs
Normal file
@@ -0,0 +1,115 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace VAR.ScreenAutomation.Controls
|
||||
{
|
||||
public class CtrImageViewer : PictureBox
|
||||
{
|
||||
#region Declarations
|
||||
|
||||
private Image _imageShow = null;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
|
||||
public Image ImageShow
|
||||
{
|
||||
get { return _imageShow; }
|
||||
set
|
||||
{
|
||||
lock (this)
|
||||
{
|
||||
_imageShow = value;
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Control life cycle
|
||||
|
||||
public CtrImageViewer()
|
||||
{
|
||||
BackColor = Color.Black;
|
||||
}
|
||||
|
||||
protected override void OnPaint(PaintEventArgs pe)
|
||||
{
|
||||
base.OnPaint(pe);
|
||||
Redraw(pe.Graphics);
|
||||
}
|
||||
|
||||
protected override void OnResize(EventArgs e)
|
||||
{
|
||||
base.OnResize(e);
|
||||
//Redraw(null);
|
||||
this.Invalidate();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private methods
|
||||
|
||||
private void Redraw(Graphics graph)
|
||||
{
|
||||
if (_imageShow == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
lock (_imageShow)
|
||||
{
|
||||
if (graph == null)
|
||||
{
|
||||
graph = this.CreateGraphics();
|
||||
}
|
||||
|
||||
// Calcular dimensiones a dibujar y centrar
|
||||
int imgDrawWidth;
|
||||
int imgDrawHeight;
|
||||
float imgDrawX = 0;
|
||||
float imgDrawY = 0;
|
||||
float relation = (float)_imageShow.Width / (float)_imageShow.Height;
|
||||
if (relation > 0)
|
||||
{
|
||||
// Imagen mas ancha que alta
|
||||
imgDrawHeight = (int)(Width / relation);
|
||||
if (imgDrawHeight > Height)
|
||||
{
|
||||
imgDrawHeight = Height;
|
||||
imgDrawWidth = (int)(Height * relation);
|
||||
imgDrawX = ((Width - imgDrawWidth) / 2.0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
imgDrawWidth = Width;
|
||||
imgDrawY = ((Height - imgDrawHeight) / 2.0f);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Imagen mas alta que ancha
|
||||
imgDrawWidth = (int)(Width * relation);
|
||||
if (imgDrawWidth > Width)
|
||||
{
|
||||
imgDrawWidth = Width;
|
||||
imgDrawHeight = (int)(Height / relation);
|
||||
imgDrawY = ((Height - imgDrawHeight) / 2.0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
imgDrawHeight = Height;
|
||||
imgDrawX = ((Width - imgDrawWidth) / 2.0f);
|
||||
}
|
||||
}
|
||||
|
||||
graph.DrawImage(_imageShow, imgDrawX, imgDrawY, imgDrawWidth, imgDrawHeight);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
182
VAR.ScreenAutomation/Controls/CtrOutput.cs
Normal file
182
VAR.ScreenAutomation/Controls/CtrOutput.cs
Normal file
@@ -0,0 +1,182 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using VAR.ScreenAutomation.Interfaces;
|
||||
|
||||
namespace VAR.ScreenAutomation.Controls
|
||||
{
|
||||
public class CtrOutput : Control, IOutputHandler
|
||||
{
|
||||
private ListBox _listBox;
|
||||
|
||||
private Timer _timer;
|
||||
|
||||
private class OutputItem
|
||||
{
|
||||
public string Text { get; set; }
|
||||
public object Data { get; set; }
|
||||
public override string ToString()
|
||||
{
|
||||
return Text;
|
||||
}
|
||||
}
|
||||
|
||||
public new event EventHandler DoubleClick;
|
||||
|
||||
public CtrOutput()
|
||||
{
|
||||
InitializeControls();
|
||||
}
|
||||
|
||||
private void InitializeControls()
|
||||
{
|
||||
_listBox = new ListBox
|
||||
{
|
||||
Dock = DockStyle.Fill,
|
||||
FormattingEnabled = true,
|
||||
Font = new System.Drawing.Font("Consolas", 9),
|
||||
BackColor = Color.Black,
|
||||
ForeColor = Color.Gray,
|
||||
SelectionMode = SelectionMode.MultiExtended,
|
||||
};
|
||||
_listBox.MouseDoubleClick += ListBox_MouseDoubleClick;
|
||||
_listBox.KeyDown += ListBox_KeyDown;
|
||||
Controls.Add(_listBox);
|
||||
|
||||
_timer = new Timer
|
||||
{
|
||||
Interval = 100,
|
||||
Enabled = true
|
||||
};
|
||||
_timer.Tick += Timer_Tick;
|
||||
|
||||
Disposed += CtrOutput_Disposed;
|
||||
}
|
||||
|
||||
private void CtrOutput_Disposed(object sender, EventArgs e)
|
||||
{
|
||||
_timer.Stop();
|
||||
_timer.Enabled = false;
|
||||
}
|
||||
|
||||
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
|
||||
{
|
||||
if ((keyData & Keys.Control) == Keys.Control && (keyData & Keys.C) == Keys.C)
|
||||
{
|
||||
CopyToClipboard();
|
||||
return true;
|
||||
}
|
||||
return base.ProcessCmdKey(ref msg, keyData);
|
||||
}
|
||||
|
||||
private void ListBox_KeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.Control && e.KeyCode == Keys.C)
|
||||
{
|
||||
CopyToClipboard();
|
||||
}
|
||||
}
|
||||
|
||||
private void CopyToClipboard()
|
||||
{
|
||||
StringBuilder sbText = new StringBuilder();
|
||||
foreach (OutputItem item in _listBox.SelectedItems)
|
||||
{
|
||||
sbText.AppendLine(item.Text);
|
||||
}
|
||||
if (sbText.Length > 0)
|
||||
{
|
||||
Clipboard.SetText(sbText.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
private void ListBox_MouseDoubleClick(object sender, MouseEventArgs e)
|
||||
{
|
||||
DoubleClick?.Invoke(sender, e);
|
||||
}
|
||||
|
||||
private void Timer_Tick(object sender, EventArgs e)
|
||||
{
|
||||
if (_updated)
|
||||
{
|
||||
UpdatePosition();
|
||||
}
|
||||
}
|
||||
|
||||
private bool _updated = false;
|
||||
private readonly List<OutputItem> _pendingOutput = new List<OutputItem>();
|
||||
|
||||
private void UpdatePosition()
|
||||
{
|
||||
lock (_pendingOutput)
|
||||
{
|
||||
EnableRepaint(new HandleRef(_listBox, _listBox.Handle), false);
|
||||
_listBox.SuspendLayout();
|
||||
foreach (OutputItem item in _pendingOutput)
|
||||
{
|
||||
_listBox.Items.Add(item);
|
||||
}
|
||||
_pendingOutput.Clear();
|
||||
_listBox.ResumeLayout();
|
||||
|
||||
int visibleItems = _listBox.ClientSize.Height / _listBox.ItemHeight;
|
||||
_listBox.TopIndex = Math.Max(_listBox.Items.Count - visibleItems + 1, 0);
|
||||
_updated = false;
|
||||
EnableRepaint(new HandleRef(_listBox, _listBox.Handle), true);
|
||||
_listBox.Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
|
||||
private static extern IntPtr SendMessage(HandleRef hWnd, Int32 Msg, IntPtr wParam, IntPtr lParam);
|
||||
|
||||
private static void EnableRepaint(HandleRef handle, bool enable)
|
||||
{
|
||||
const int WM_SETREDRAW = 0x000B;
|
||||
SendMessage(handle, WM_SETREDRAW, new IntPtr(enable ? 1 : 0), IntPtr.Zero);
|
||||
}
|
||||
|
||||
public void Clean()
|
||||
{
|
||||
if (_listBox.InvokeRequired)
|
||||
{
|
||||
_listBox.Invoke((MethodInvoker)(() =>
|
||||
{
|
||||
_listBox.Items.Clear();
|
||||
_updated = true;
|
||||
}));
|
||||
}
|
||||
else
|
||||
{
|
||||
_listBox.Items.Clear();
|
||||
_updated = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void AddLine(string line, object data = null)
|
||||
{
|
||||
lock (_pendingOutput)
|
||||
{
|
||||
_pendingOutput.Add(new OutputItem { Text = line, Data = data, });
|
||||
_updated = true;
|
||||
}
|
||||
}
|
||||
|
||||
public string GetCurrentText()
|
||||
{
|
||||
if (_listBox.SelectedItems.Count == 0) { return null; }
|
||||
OutputItem item = (OutputItem)_listBox.SelectedItems[0];
|
||||
return item?.Text;
|
||||
}
|
||||
|
||||
public object GetCurrentData()
|
||||
{
|
||||
if (_listBox.SelectedItems.Count == 0) { return null; }
|
||||
OutputItem item = (OutputItem)_listBox.SelectedItems[0];
|
||||
return item?.Data;
|
||||
}
|
||||
}
|
||||
}
|
||||
169
VAR.ScreenAutomation/FrmScreenAutomation.Designer.cs
generated
Normal file
169
VAR.ScreenAutomation/FrmScreenAutomation.Designer.cs
generated
Normal file
@@ -0,0 +1,169 @@
|
||||
namespace VAR.ScreenAutomation
|
||||
{
|
||||
partial class FrmScreenAutomation
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.picCapturer = new System.Windows.Forms.PictureBox();
|
||||
this.splitMain = new System.Windows.Forms.SplitContainer();
|
||||
this.splitOutput = new System.Windows.Forms.SplitContainer();
|
||||
this.picPreview = new VAR.ScreenAutomation.Controls.CtrImageViewer();
|
||||
this.btnStartEnd = new System.Windows.Forms.Button();
|
||||
this.ctrOutput = new VAR.ScreenAutomation.Controls.CtrOutput();
|
||||
((System.ComponentModel.ISupportInitialize)(this.picCapturer)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.splitMain)).BeginInit();
|
||||
this.splitMain.Panel1.SuspendLayout();
|
||||
this.splitMain.Panel2.SuspendLayout();
|
||||
this.splitMain.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.splitOutput)).BeginInit();
|
||||
this.splitOutput.Panel1.SuspendLayout();
|
||||
this.splitOutput.Panel2.SuspendLayout();
|
||||
this.splitOutput.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.picPreview)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// picCapturer
|
||||
//
|
||||
this.picCapturer.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.picCapturer.Location = new System.Drawing.Point(4, 4);
|
||||
this.picCapturer.Margin = new System.Windows.Forms.Padding(4);
|
||||
this.picCapturer.Name = "picCapturer";
|
||||
this.picCapturer.Padding = new System.Windows.Forms.Padding(10);
|
||||
this.picCapturer.Size = new System.Drawing.Size(424, 799);
|
||||
this.picCapturer.TabIndex = 0;
|
||||
this.picCapturer.TabStop = false;
|
||||
//
|
||||
// splitMain
|
||||
//
|
||||
this.splitMain.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.splitMain.FixedPanel = System.Windows.Forms.FixedPanel.Panel1;
|
||||
this.splitMain.Location = new System.Drawing.Point(0, 0);
|
||||
this.splitMain.Margin = new System.Windows.Forms.Padding(10);
|
||||
this.splitMain.Name = "splitMain";
|
||||
//
|
||||
// splitMain.Panel1
|
||||
//
|
||||
this.splitMain.Panel1.Controls.Add(this.splitOutput);
|
||||
//
|
||||
// splitMain.Panel2
|
||||
//
|
||||
this.splitMain.Panel2.Controls.Add(this.picCapturer);
|
||||
this.splitMain.Size = new System.Drawing.Size(754, 816);
|
||||
this.splitMain.SplitterDistance = 309;
|
||||
this.splitMain.TabIndex = 3;
|
||||
//
|
||||
// splitOutput
|
||||
//
|
||||
this.splitOutput.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.splitOutput.Location = new System.Drawing.Point(0, 0);
|
||||
this.splitOutput.Name = "splitOutput";
|
||||
this.splitOutput.Orientation = System.Windows.Forms.Orientation.Horizontal;
|
||||
//
|
||||
// splitOutput.Panel1
|
||||
//
|
||||
this.splitOutput.Panel1.Controls.Add(this.picPreview);
|
||||
//
|
||||
// splitOutput.Panel2
|
||||
//
|
||||
this.splitOutput.Panel2.Controls.Add(this.btnStartEnd);
|
||||
this.splitOutput.Panel2.Controls.Add(this.ctrOutput);
|
||||
this.splitOutput.Size = new System.Drawing.Size(309, 816);
|
||||
this.splitOutput.SplitterDistance = 371;
|
||||
this.splitOutput.TabIndex = 4;
|
||||
//
|
||||
// picPreview
|
||||
//
|
||||
this.picPreview.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.picPreview.BackColor = System.Drawing.Color.Black;
|
||||
this.picPreview.ImageShow = null;
|
||||
this.picPreview.Location = new System.Drawing.Point(12, 12);
|
||||
this.picPreview.Name = "picPreview";
|
||||
this.picPreview.Size = new System.Drawing.Size(294, 356);
|
||||
this.picPreview.TabIndex = 1;
|
||||
this.picPreview.TabStop = false;
|
||||
//
|
||||
// btnStartEnd
|
||||
//
|
||||
this.btnStartEnd.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.btnStartEnd.Location = new System.Drawing.Point(12, 3);
|
||||
this.btnStartEnd.Name = "btnStartEnd";
|
||||
this.btnStartEnd.Size = new System.Drawing.Size(294, 39);
|
||||
this.btnStartEnd.TabIndex = 3;
|
||||
this.btnStartEnd.Text = "Start";
|
||||
this.btnStartEnd.UseVisualStyleBackColor = true;
|
||||
this.btnStartEnd.Click += new System.EventHandler(this.BtnStartEnd_Click);
|
||||
//
|
||||
// ctrOutput
|
||||
//
|
||||
this.ctrOutput.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.ctrOutput.Location = new System.Drawing.Point(12, 48);
|
||||
this.ctrOutput.Name = "ctrOutput";
|
||||
this.ctrOutput.Size = new System.Drawing.Size(294, 380);
|
||||
this.ctrOutput.TabIndex = 2;
|
||||
this.ctrOutput.Text = "ctrOutput1";
|
||||
//
|
||||
// FrmScreenAutomation
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(754, 816);
|
||||
this.Controls.Add(this.splitMain);
|
||||
this.Margin = new System.Windows.Forms.Padding(4);
|
||||
this.Name = "FrmScreenAutomation";
|
||||
this.Text = "ScreenAutomation";
|
||||
this.Load += new System.EventHandler(this.FrmScreenAutomation_Load);
|
||||
((System.ComponentModel.ISupportInitialize)(this.picCapturer)).EndInit();
|
||||
this.splitMain.Panel1.ResumeLayout(false);
|
||||
this.splitMain.Panel2.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)(this.splitMain)).EndInit();
|
||||
this.splitMain.ResumeLayout(false);
|
||||
this.splitOutput.Panel1.ResumeLayout(false);
|
||||
this.splitOutput.Panel2.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)(this.splitOutput)).EndInit();
|
||||
this.splitOutput.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)(this.picPreview)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.PictureBox picCapturer;
|
||||
private Controls.CtrImageViewer picPreview;
|
||||
private Controls.CtrOutput ctrOutput;
|
||||
private System.Windows.Forms.SplitContainer splitMain;
|
||||
private System.Windows.Forms.SplitContainer splitOutput;
|
||||
private System.Windows.Forms.Button btnStartEnd;
|
||||
}
|
||||
}
|
||||
|
||||
96
VAR.ScreenAutomation/FrmScreenAutomation.cs
Normal file
96
VAR.ScreenAutomation/FrmScreenAutomation.cs
Normal file
@@ -0,0 +1,96 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
using VAR.ScreenAutomation.Bots;
|
||||
using VAR.ScreenAutomation.Code;
|
||||
using VAR.ScreenAutomation.Interfaces;
|
||||
|
||||
namespace VAR.ScreenAutomation
|
||||
{
|
||||
public partial class FrmScreenAutomation : Form
|
||||
{
|
||||
private bool _running = false;
|
||||
private IAutomationBot _automationBot = new DummyBot();
|
||||
|
||||
private Timer timTicker;
|
||||
private Bitmap bmpScreen = null;
|
||||
|
||||
public FrmScreenAutomation()
|
||||
{
|
||||
AutoScaleMode = AutoScaleMode.None;
|
||||
AutoScaleDimensions = new SizeF(1, 1);
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void FrmScreenAutomation_Load(object sender, EventArgs e)
|
||||
{
|
||||
SetStyle(ControlStyles.UserPaint, true);
|
||||
SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
|
||||
SetStyle(ControlStyles.SupportsTransparentBackColor, true);
|
||||
TransparencyKey = Color.LimeGreen;
|
||||
picCapturer.BackColor = Color.LimeGreen;
|
||||
|
||||
if (components == null) { components = new Container(); }
|
||||
timTicker = new Timer(components)
|
||||
{
|
||||
Interval = 16,
|
||||
};
|
||||
timTicker.Tick += TimTicker_Tick;
|
||||
timTicker.Enabled = true;
|
||||
timTicker.Start();
|
||||
|
||||
WindowHandling.WindowSetTopLevel(this);
|
||||
}
|
||||
|
||||
private void TimTicker_Tick(object sender, EventArgs e)
|
||||
{
|
||||
timTicker.Stop();
|
||||
|
||||
bmpScreen = Screenshoter.CaptureControl(picCapturer, bmpScreen);
|
||||
|
||||
if (_automationBot != null && _running)
|
||||
{
|
||||
bmpScreen = _automationBot.Process(bmpScreen, ctrOutput);
|
||||
string responseKeys = _automationBot.ResponseKeys();
|
||||
if (string.IsNullOrEmpty(responseKeys) == false && WindowHandling.ApplicationIsActivated() == false)
|
||||
{
|
||||
SendKeys.Send(responseKeys);
|
||||
}
|
||||
}
|
||||
picPreview.ImageShow = bmpScreen;
|
||||
|
||||
timTicker.Start();
|
||||
}
|
||||
|
||||
private void BtnStartEnd_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (_running)
|
||||
{
|
||||
End();
|
||||
}
|
||||
else
|
||||
{
|
||||
Start();
|
||||
}
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
if (_running) { return; }
|
||||
_running = true;
|
||||
btnStartEnd.Text = "End";
|
||||
_automationBot?.Init(ctrOutput);
|
||||
Point pointCapturerCenter = picCapturer.PointToScreen(new Point(picCapturer.Width / 2, picCapturer.Height / 2));
|
||||
Mouse.SetPosition((uint)pointCapturerCenter.X, (uint)pointCapturerCenter.Y);
|
||||
Mouse.Click(Mouse.MouseButtons.Left);
|
||||
}
|
||||
|
||||
private void End()
|
||||
{
|
||||
if (_running == false) { return; }
|
||||
_running = false;
|
||||
btnStartEnd.Text = "Start";
|
||||
}
|
||||
}
|
||||
}
|
||||
120
VAR.ScreenAutomation/FrmScreenAutomation.resx
Normal file
120
VAR.ScreenAutomation/FrmScreenAutomation.resx
Normal file
@@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
11
VAR.ScreenAutomation/Interfaces/IAutomationBot.cs
Normal file
11
VAR.ScreenAutomation/Interfaces/IAutomationBot.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
using System.Drawing;
|
||||
|
||||
namespace VAR.ScreenAutomation.Interfaces
|
||||
{
|
||||
public interface IAutomationBot
|
||||
{
|
||||
void Init(IOutputHandler output);
|
||||
Bitmap Process(Bitmap bmpInput, IOutputHandler output);
|
||||
string ResponseKeys();
|
||||
}
|
||||
}
|
||||
8
VAR.ScreenAutomation/Interfaces/IOutputHandler.cs
Normal file
8
VAR.ScreenAutomation/Interfaces/IOutputHandler.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
namespace VAR.ScreenAutomation.Interfaces
|
||||
{
|
||||
public interface IOutputHandler
|
||||
{
|
||||
void Clean();
|
||||
void AddLine(string line, object data = null);
|
||||
}
|
||||
}
|
||||
19
VAR.ScreenAutomation/Program.cs
Normal file
19
VAR.ScreenAutomation/Program.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace VAR.ScreenAutomation
|
||||
{
|
||||
internal static class Program
|
||||
{
|
||||
/// <summary>
|
||||
/// The main entry point for the application.
|
||||
/// </summary>
|
||||
[STAThread]
|
||||
private static void Main()
|
||||
{
|
||||
Application.EnableVisualStyles();
|
||||
Application.SetCompatibleTextRenderingDefault(false);
|
||||
Application.Run(new FrmScreenAutomation());
|
||||
}
|
||||
}
|
||||
}
|
||||
36
VAR.ScreenAutomation/Properties/AssemblyInfo.cs
Normal file
36
VAR.ScreenAutomation/Properties/AssemblyInfo.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("VAR.ScreenAutomation")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("VAR.ScreenAutomation")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2019")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("e2be8e2a-3422-42a6-82fa-5e0ccdc42032")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
71
VAR.ScreenAutomation/Properties/Resources.Designer.cs
generated
Normal file
71
VAR.ScreenAutomation/Properties/Resources.Designer.cs
generated
Normal file
@@ -0,0 +1,71 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.42000
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace VAR.ScreenAutomation.Properties
|
||||
{
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||
/// </summary>
|
||||
// This class was auto-generated by the StronglyTypedResourceBuilder
|
||||
// class via a tool like ResGen or Visual Studio.
|
||||
// To add or remove a member, edit your .ResX file then rerun ResGen
|
||||
// with the /str option, or rebuild your VS project.
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
internal class Resources
|
||||
{
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal Resources()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the cached ResourceManager instance used by this class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Resources.ResourceManager ResourceManager
|
||||
{
|
||||
get
|
||||
{
|
||||
if ((resourceMan == null))
|
||||
{
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("VAR.ScreenAutomation.Properties.Resources", typeof(Resources).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overrides the current thread's CurrentUICulture property for all
|
||||
/// resource lookups using this strongly typed resource class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture
|
||||
{
|
||||
get
|
||||
{
|
||||
return resourceCulture;
|
||||
}
|
||||
set
|
||||
{
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
117
VAR.ScreenAutomation/Properties/Resources.resx
Normal file
117
VAR.ScreenAutomation/Properties/Resources.resx
Normal file
@@ -0,0 +1,117 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
30
VAR.ScreenAutomation/Properties/Settings.Designer.cs
generated
Normal file
30
VAR.ScreenAutomation/Properties/Settings.Designer.cs
generated
Normal file
@@ -0,0 +1,30 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.42000
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace VAR.ScreenAutomation.Properties
|
||||
{
|
||||
|
||||
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
|
||||
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
|
||||
{
|
||||
|
||||
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
||||
|
||||
public static Settings Default
|
||||
{
|
||||
get
|
||||
{
|
||||
return defaultInstance;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
7
VAR.ScreenAutomation/Properties/Settings.settings
Normal file
7
VAR.ScreenAutomation/Properties/Settings.settings
Normal file
@@ -0,0 +1,7 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
|
||||
<Profiles>
|
||||
<Profile Name="(Default)" />
|
||||
</Profiles>
|
||||
<Settings />
|
||||
</SettingsFile>
|
||||
99
VAR.ScreenAutomation/VAR.ScreenAutomation.csproj
Normal file
99
VAR.ScreenAutomation/VAR.ScreenAutomation.csproj
Normal file
@@ -0,0 +1,99 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{E2BE8E2A-3422-42A6-82FA-5E0CCDC42032}</ProjectGuid>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<RootNamespace>VAR.ScreenAutomation</RootNamespace>
|
||||
<AssemblyName>VAR.ScreenAutomation</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
<Deterministic>true</Deterministic>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<ApplicationManifest>app.manifest</ApplicationManifest>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Deployment" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Bots\DummyBot.cs" />
|
||||
<Compile Include="Code\Mouse.cs" />
|
||||
<Compile Include="Code\Screenshoter.cs" />
|
||||
<Compile Include="Code\WindowHandling.cs" />
|
||||
<Compile Include="Controls\CtrImageViewer.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Controls\CtrOutput.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="FrmScreenAutomation.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="FrmScreenAutomation.Designer.cs">
|
||||
<DependentUpon>FrmScreenAutomation.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Interfaces\IAutomationBot.cs" />
|
||||
<Compile Include="Interfaces\IOutputHandler.cs" />
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<EmbeddedResource Include="FrmScreenAutomation.resx">
|
||||
<DependentUpon>FrmScreenAutomation.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
<Compile Include="Properties\Resources.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
</Compile>
|
||||
<None Include="app.manifest" />
|
||||
<None Include="Properties\Settings.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||
</None>
|
||||
<Compile Include="Properties\Settings.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Settings.settings</DependentUpon>
|
||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
76
VAR.ScreenAutomation/app.manifest
Normal file
76
VAR.ScreenAutomation/app.manifest
Normal file
@@ -0,0 +1,76 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<assemblyIdentity version="1.0.0.0" name="MyApplication.app"/>
|
||||
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
|
||||
<security>
|
||||
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
|
||||
<!-- UAC Manifest Options
|
||||
If you want to change the Windows User Account Control level replace the
|
||||
requestedExecutionLevel node with one of the following.
|
||||
|
||||
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
|
||||
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
|
||||
<requestedExecutionLevel level="highestAvailable" uiAccess="false" />
|
||||
|
||||
Specifying requestedExecutionLevel element will disable file and registry virtualization.
|
||||
Remove this element if your application requires this virtualization for backwards
|
||||
compatibility.
|
||||
-->
|
||||
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
|
||||
</requestedPrivileges>
|
||||
</security>
|
||||
</trustInfo>
|
||||
|
||||
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
|
||||
<application>
|
||||
<!-- A list of the Windows versions that this application has been tested on
|
||||
and is designed to work with. Uncomment the appropriate elements
|
||||
and Windows will automatically select the most compatible environment. -->
|
||||
|
||||
<!-- Windows Vista -->
|
||||
<!--<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}" />-->
|
||||
|
||||
<!-- Windows 7 -->
|
||||
<!--<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}" />-->
|
||||
|
||||
<!-- Windows 8 -->
|
||||
<!--<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}" />-->
|
||||
|
||||
<!-- Windows 8.1 -->
|
||||
<!--<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}" />-->
|
||||
|
||||
<!-- Windows 10 -->
|
||||
<!--<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />-->
|
||||
|
||||
</application>
|
||||
</compatibility>
|
||||
|
||||
<!-- Indicates that the application is DPI-aware and will not be automatically scaled by Windows at higher
|
||||
DPIs. Windows Presentation Foundation (WPF) applications are automatically DPI-aware and do not need
|
||||
to opt in. Windows Forms applications targeting .NET Framework 4.6 that opt into this setting, should
|
||||
also set the 'EnableWindowsFormsHighDpiAutoResizing' setting to 'true' in their app.config. -->
|
||||
|
||||
<application xmlns="urn:schemas-microsoft-com:asm.v3">
|
||||
<windowsSettings>
|
||||
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware>
|
||||
</windowsSettings>
|
||||
</application>
|
||||
|
||||
|
||||
<!-- Enable themes for Windows common controls and dialogs (Windows XP and later) -->
|
||||
<!--
|
||||
<dependency>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity
|
||||
type="win32"
|
||||
name="Microsoft.Windows.Common-Controls"
|
||||
version="6.0.0.0"
|
||||
processorArchitecture="*"
|
||||
publicKeyToken="6595b64144ccf1df"
|
||||
language="*"
|
||||
/>
|
||||
</dependentAssembly>
|
||||
</dependency>
|
||||
-->
|
||||
|
||||
</assembly>
|
||||
Reference in New Issue
Block a user