TC中Regions对象的使用介绍

在TC中,提供了一个Regions对象集合,专门管理图像对象,可以通过以下方法添加图像对象到Regions集合中:

//添加图像方式:
//1.Add images from the Regions editor
//2.Add images from the Project Explorer
//3.Add images from the Image Viewer
//4.Add images during recording
//5.Add images from scrīpts

Regions对象封装了几个常用的方法,如Regions.AddPicture(添加图像)、Regions.GetPicture(获取图像)、Regions.FindRegion(查找图像)、Picture.Find(查找图像)等,具体使用如下:

//在脚本中添加图像
procedure AddImageFromscrīpt;
begin
  //添加主窗体图像
  Regions.AddPicture(Aliases.TCSampleForm,'TCSampleForm');
  //添加主窗体中操作数1的图像
  Regions.AddPicture(Aliases.TCSampleOperand1,'TCSampleOperand1'); 
end;

//回放脚本过程中截取图像与在Regions集合中的图像进行比较
procedure CompareImage_Playback;   
begin
  if not Regions.Compare('TCSampleFormChangeName', Aliases.TCSampleForm) then
    Log.Error('The compared regions are not identical.', Aliases.TCSampleForm.Name);  
end;

//Regions集合中两个图像进行比较
procedure CompareImage_Regions; 
begin
  if not Regions.Compare('TCSampleFormChangeName', 'TCSampleForm') then
    Log.Error('The compared regions are not identical.', 'TCSampleForm');
end;

//使用Picture对象比较两个图像  
procedure CompareImage_Picture;
var pict1,pict2 : olevariant;
begin  
  pict1 := Regions.GetPicture('TCSampleForm');
  pict2 := Regions.GetPicture('TCSampleFormChangeName');
  if not pict1.Compare(pict2) then
    Log.Error('The compared regions are not identical.');    
end;

//使用Regions对象的FindRegion方法查找图像 
procedure FindImage_Regions;
var pict1,pict2 : olevariant;
begin  
  if (Regions.FindRegion('TCSampleOperand1','TCSampleForm') = nil) then
    Log.Warning('Picture not found.');    
end;

//使用Picture对象的Find方法查找图像
procedure FindImage_Picture;
var pict1,pict2 : olevariant;
begin  
  pict1 := Regions.GetPicture('TCSampleForm');
  pict2 := Regions.GetPicture('TCSampleOperand1');
  if (pict1.Find(pict2) = nil) then
    Log.Warning('Picture not found.');       
end;

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值