使用按键精灵识别点击区域进行点击

您所在的位置:网站首页 按键精灵固定窗口位置 使用按键精灵识别点击区域进行点击

使用按键精灵识别点击区域进行点击

2024-06-06 08:03| 来源: 网络整理| 查看: 265

使用按键精灵,我们可以录制脚本,根据组件坐标进行一些自动化的操作。

但是,有时组件的坐标可能不是一定的,会发生细微的变化。

我们可以根据图片识别点击区域进行点击。

一、获取点击区域图片

1.打开按键精灵软件,点击抓抓

 

 2.点击图像->截屏->框选区域->位图另存为,存储位图(bmp)。

 

 3.在附件中添加该位图(bmp)为附件。

 

 二、书写脚本

1.新建一个脚本

2.输入如下代码

Dim intX, intY Rem 开始找图 FindPic 0, 0, 1920, 1080, "Attachment:\test2.bmp", 0.9, intX, intY TracePrint intX TracePrint intY If intX > 0 And intY > 0 Then MoveTo intX+20,intY+20 LeftClick 1 Delay 100 Goto 开始找图 Else Delay 500 Goto 开始找图 End If

其中,1920和1080是屏幕的分辨率。

3.点击调试->启动,则会输出点击区域图片的坐标值,并自动进行点击操作。

4.下面是寻找多个点击位置,并进行点击的代码

Dim intX, intY Rem 开始找图 FindPic 0, 0, 1920, 1080, "Attachment:\circle.bmp", 0.9, intX, intY TracePrint intX TracePrint intY If intX > 0 And intY > 0 Then MoveTo intX+20,intY+20 LeftClick 1 Delay 100 Else Delay 500 End If FindPic 0, 0, 1920, 1080, "Attachment:\confirm.bmp", 0.9, intX, intY TracePrint intX TracePrint intY If intX > 0 And intY > 0 Then MoveTo intX+20,intY+20 LeftClick 1 Delay 100 Else Delay 500 End If FindPic 0, 0, 1920, 1080, "Attachment:\continue.bmp", 0.9, intX, intY TracePrint intX TracePrint intY If intX > 0 And intY > 0 Then MoveTo intX+20,intY+20 LeftClick 1 Delay 100 Else Delay 500 End If FindPic 0, 0, 1920, 1080, "Attachment:\next.bmp", 0.9, intX, intY TracePrint intX TracePrint intY If intX > 0 And intY > 0 Then MoveTo intX+20,intY+20 LeftClick 1 Delay 100 Else Delay 500 End If Goto 开始找图

即可。



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3