feat: TapByCV WithTapRandomRect

This commit is contained in:
lilong.129
2025-03-17 18:06:32 +08:00
parent 182de16751
commit 5e2f33b362
5 changed files with 29 additions and 8 deletions
+10 -3
View File
@@ -32,15 +32,22 @@ func (dExt *XTDriver) TapByOCR(text string, opts ...option.ActionOption) error {
}
func (dExt *XTDriver) TapByCV(opts ...option.ActionOption) error {
options := option.NewActionOptions(opts...)
actionOptions := option.NewActionOptions(opts...)
point, err := dExt.FindUIResult(opts...)
uiResult, err := dExt.FindUIResult(opts...)
if err != nil {
if options.IgnoreNotFoundError {
if actionOptions.IgnoreNotFoundError {
return nil
}
return err
}
var point ai.PointF
if actionOptions.TapRandomRect {
point = uiResult.RandomPoint()
} else {
point = uiResult.Center()
}
return dExt.TapAbsXY(point.X, point.Y, opts...)
}