Skip to content

[Bug]: Automatic Naming "text in the image" silently produces a timestamp (works in SikuliX 2.0.6) #456

Description

Summary

Preferences → Screen Capturing → Automatic Naming offers "text in the image", which should propose a filename for a captured image from text found inside it — a window title, a button label. In OculiX it silently produces a timestamp instead, exactly like the "time stamp" option. No error, no log message, nothing to suggest the setting had no effect.

It still works in SikuliX 2.0.6, so this is a regression rather than a feature that was never finished. Verified on Ubuntu 24.04 with sikulixidelinux-2.0.6.jar — useful as a reference build for before/after testing.

Steps to reproduce

  1. Preferences → Screen Capturing → Automatic Naming → text in the image, then OK
  2. Capture a region containing clearly legible text (a window title bar works well)
  3. The image is saved with a timestamp name; the text in the image is ignored

Expected: the proposed filename derives from the recognised text.

Cause

The OCR branch in ButtonCapture.update() is commented out — IDE/src/main/java/org/sikuli/ide/ButtonCapture.java:

if (prefs.getAutoNamingMethod() == PreferencesUser.AUTO_NAMING_OFF) {
  givenName = askForScreenshotName();
}
if (givenName == null || givenName.isEmpty()) {
  givenName = Settings.getTimestamp();
}
//        if (prefs.getAutoNamingMethod() == PreferencesUser.AUTO_NAMING_TIMESTAMP) {
//          ;
//        } else if (naming == PreferencesUser.AUTO_NAMING_OCR) {
//          filename = PatternPaneNaming.getFilenameFromImage(capturedImage.get());
//          if (filename == null || filename.length() == 0) {
//            filename = Settings.getTimestamp();
//          }
//        } else {
//          ...

Only AUTO_NAMING_OFF is handled. AUTO_NAMING_OCR and AUTO_NAMING_TIMESTAMP both fall through to Settings.getTimestamp(), which is why the two options are indistinguishable.

The helper the commented code calls is still present and not stubbed — PatternPaneNaming.getFilenameFromImage(BufferedImage) at IDE/src/main/java/org/sikuli/ide/PatternPaneNaming.java:131 — so re-enabling may be mostly a matter of restoring the call site and updating it to the current OCR API. Worth checking against 2.0.6 to see what else differs, since the code above appears to have been inactive for some time yet 2.0.6 behaves correctly.

Related wrinkle: the broken option is the fallback default

PreferencesUser.getAutoNamingMethod() returns AUTO_NAMING_OCR when the preference has never been written:

public int getAutoNamingMethod() {
  return pref.getInt("AUTO_NAMING", AUTO_NAMING_OCR);
}

setDefaults() writes AUTO_NAMING_TIMESTAMP, so an install that has gone through it is fine. But any path that reads the preference without setDefaults() having run lands on the non-functional option. Whether that is reachable in practice is worth confirming; if it is, users would get timestamps while the dialog shows "text in the image" selected.

Suggested handling

Two independent pieces:

  • Restore the behaviour — the substantive fix.
  • Meanwhile, stop offering a control that does nothing. Greying the option out, or noting it in the dialog, would at least tell users the setting is inert. Right now the only way to discover it is to compare output filenames and infer.

Notes

Found while documenting the Preferences dialog for the docs site, not while working on the dialog itself. Unrelated to #335 and deliberately not bundled into it.

Environment: OculiX 4.0.0, macOS 26.6 (Apple M4 Pro) and Ubuntu 24.04 x86-64. Reference build showing correct behaviour: SikuliX 2.0.6 on Ubuntu 24.04.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions