diff --git a/internal/version/VERSION b/internal/version/VERSION index b038c688..5bb3cbc9 100644 --- a/internal/version/VERSION +++ b/internal/version/VERSION @@ -1 +1 @@ -v5.0.0-beta-2503172040 +v5.0.0-beta-2503251404 diff --git a/uixt/driver_ext_screenshot.go b/uixt/driver_ext_screenshot.go index 674b4a5f..e562ac6d 100644 --- a/uixt/driver_ext_screenshot.go +++ b/uixt/driver_ext_screenshot.go @@ -150,6 +150,25 @@ func (dExt *XTDriver) FindScreenText(text string, opts ...option.ActionOption) ( if options.ScreenShotFileName == "" { opts = append(opts, option.WithScreenShotFileName(fmt.Sprintf("find_screen_text_%s", text))) } + + // convert relative scope to absolute scope + if options.AbsScope == nil && len(options.Scope) == 4 { + windowSize, err := dExt.WindowSize() + if err != nil { + return ai.OCRText{}, err + } + absScope := option.AbsScope{ + int(options.Scope[0] * float64(windowSize.Width)), + int(options.Scope[1] * float64(windowSize.Height)), + int(options.Scope[2] * float64(windowSize.Width)), + int(options.Scope[3] * float64(windowSize.Height)), + } + opts = append(opts, option.WithAbsScope( + absScope[0], absScope[1], absScope[2], absScope[3])) + log.Info().Interface("scope", options.Scope). + Interface("absScope", absScope).Msg("convert to abs scope") + } + ocrTexts, err := dExt.GetScreenTexts(opts...) if err != nil { return diff --git a/uixt/driver_ext_test.go b/uixt/driver_ext_test.go index 243d1493..8dd3215e 100644 --- a/uixt/driver_ext_test.go +++ b/uixt/driver_ext_test.go @@ -119,7 +119,7 @@ func TestDriverExt_Seek(t *testing.T) { func TestDriverExt_TapByOCR(t *testing.T) { driver := setupDriverExt(t) - err := driver.TapByOCR("天气") + err := driver.TapByOCR("天气", option.WithScope(0, 0.7, 0.3, 1)) assert.Nil(t, err) }