Прошло много времени с тех пор, как я это сделал, но я думаю, что вы можете переместить курсор мыши в положение с помощью:
Cursor.Position = Drawing.Point(x, y)
Вы можете определенно захватить экран (если вы имеете в виду скриншот). Это немного беспорядок копирования / вставки, но:
public class ScreenCapture : IDisposable
{
private string filePath = "";
private Attachment attachment;
private Bitmap bitmap = new Bitmap(1, 1);
private MemoryStream imageStream = new MemoryStream();
public ScreenCapture() { }
void IDisposable.Dispose()
{
Dispose();
}
public void Dispose()
{
if (bitmap != null)
bitmap.Dispose();
if (imageStream != null)
imageStream.Close();
}
# region Property Methods
public string FilePath
{
get { return filePath; }
}
# endregion // Property Methods
# region Private Methods
/// <summary>
/// Capture the specified region into a bitmap object.
/// </summary>
/// <param name="sourcePoint">The point at the upper-left corner of the source rectangle.</param>
/// <param name="destinationPoint">The point at the upper-left corner of the destination rectangle.</param>
/// <param name="selectionRectangle">The size of the area to be transferred.</param>
private void CaptureRegionToBitmap(Point sourcePoint, Point destinationPoint, Rectangle selectionRectangle)
{
if (bitmap != null)
bitmap.Dispose();
bitmap = new Bitmap(selectionRectangle.Width, selectionRectangle.Height);
using (Graphics g = Graphics.FromImage(bitmap))
g.CopyFromScreen(sourcePoint, destinationPoint, selectionRectangle.Size);
}
# endregion // Private Methods
# region Public Methods
/// <summary>
/// Create an attachment to append to an email message.
/// </summary>
/// <returns>Returns an email attachment.</returns>
public Attachment GenerateAttachment()
{
return GenerateAttachment("");
}
/// <summary>
/// Create an attachment from the generated bitmap to append to an email message.
/// </summary>
/// <param name="imageName">Provide a name for the attachment.</param>
/// <returns>Returns email attachment.</returns>
public Attachment GenerateAttachment(string imageName)
{
if (attachment != null)
attachment.Dispose();
if (imageName == null || imageName.Trim() == "")
imageName = Core.LoginUserName.ToLower() + "_image.png";
bitmap.Save(imageStream, ImageFormat.Png);
imageStream.Position = 0;
attachment = new Attachment(imageStream, imageName, "image/png");
return attachment;
}
/// <summary>
/// Capture the entire screen to a Bitmap object stored in memory.
/// </summary>
public void CaptureFullScreen()
{
CaptureRegionToBitmap(new Point(0, 0), new Point(0, 0), SystemInformation.VirtualScreen);
}
/// <summary>
/// Save the generated bitmap to a physical file on disk.
/// </summary>
/// <param name="filePath"></param>
/// <returns>Returns True if save was successful; otherwise False.</returns>
public bool SaveToDisk(string filePath)
{
bool saveSuccessful = false;
try
{
bitmap.Save(filePath, ImageFormat.Png);
this.filePath = filePath;
saveSuccessful = true;
}
catch { }
return saveSuccessful;
}
# endregion // Public Methods
}
Я забыл название этого инструмента, но у Microsoft есть инструмент тестирования / автоматизации пользовательского интерфейса, который взаимодействует с любым приложением Windows, и они подключаются к доступности Windows (для пользователей с ограниченными возможностями / инвалидов), чтобы программно взаимодействовать со всем.
Это также может представлять интерес: Основы автоматизации пользовательского интерфейса (MSDN)