//********************************************************************************
//
//文件名(File Name): SikuliActions.cs
//功能描述(Description): SikuliUI 的公共操作方法
//作 者(Author): Cary
//日 期(Create Date): 2017-09-11
//修改记录(Revision History): NO
//
//********************************************************************************
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;
using System.IO;
using System.Diagnostics;
using SikuliSharp;
namespace NetBrain.Common.Utility
{
public class SikuliActions
{
///
/// 根据图片路径,单击图片指定的位置
///
///
图片路径
///
public static bool Click(string Pic_FileName, int x, int y, float similarity = 0.8f)
{
bool result = false;
try
{
using (var session = Sikuli.CreateSession())
{
IPattern p_filename = Patterns.FromFile(Pic_FileName, similarity);
if (session.Exists(p_filename))
{
session.Click(p_filename, new Point(x, y));
}
result = true;
}
}
catch { }
return result;
}
///
/// 根据图片路径,查看实际的场景是否存在期望对比镜像图片
///
///
图片路径
///
public static bool IsPicExist(string Pic_FileName, float similarity = 0.8f)
{
bool result = false;
try
{
using (var session = Sikuli.CreateSession())
{
IPattern p_filename = Patterns.FromFile(Pic_FileName, similarity);
if (session.Exists(p_filename))
{
result = true;
}
}
}
catch { }
return result;
}
///
/// 根据图片路径,双击图片指定的位置
///
///
图片路径
///
public static bool DoubleClick(string Pic_FileName, int x, int y, float similarity = 0.8f)
{
bool result = false;
try
{
using (var session = Sikuli.CreateSession())
{
IPattern p_filename = Patterns.FromFile(Pic_FileName, similarity);
if (session.Exists(p_filename))
{
session.DoubleClick(p_filename, new Point(x, y));
result = true;
}
}
}
catch { }
return result;
}
}
}