|
对话框的类型是一样的,只是对话框内的图标不一样,可以用采用这样的思路解决:
1、预先用CaptureBitmap函数把错误图标(X)和警告图标(!)的图像分别截获并保存到指定位置
2、运行时用同样方法截获图像与预存的图片进行比较,从而判断出现的是错误图标还是警告图标
下面是一个例子:
Dialog("Login").Dialog("Flight Reservations").Static("Static").CaptureBitmap "D:\icon_runtime.png",True
File1 = "D:\icon.png"
File2 = "D:\icon_runtime.png"
Set oScreenCapture = CreateObject("KnowledgeInbox.ScreenCapture")
'Get count of pixels which are different in both images
PixelCountDiff = oScreenCapture.CompareImages (File1,File2, "[PixelDiffCount]")
'Get percentage of pixels which are different in both images
PixelDiffPerc = oScreenCapture.CompareImages (File1, File2, "[PixelDiffPerc]")
MsgBox PixelCountDiff
MsgBox PixelDiffPerc
'Save the difference image
Call oScreenCapture.CompareImages (File1, File2, "C:\Difference.png")
'Destroy the object
Set oScreenCapture = Nothing
例子中File1是预存的图片,File2是运行时截获的图片,例子中使用了ScreenCapture API,可从这里下载:
http://knowledgeinbox.com/downlo ... comparison-com-api/ |
|