[1.1.x] Linux: Capture: Problem with not recognized window borders

Asked by Edmundo V. Neto on 2017-07-12

*********** please comment in related bug


I recently updated my system to Linux Mint 18.2 with Cinnamon and I'm currently using Sikuli 1.1.2 Nightly Build 2017-06-04.
(previously I was using Linux Mint 17.3 with that same version of Sikuli)

The image capture stopped working with a strange behavior. When I try to capture an image using the IDE and the screen darkens, the borders of the windows are displaced and disfigured, sometime the entire window is displaced a little lower than the original position, the internal content of the screen remains fine. Seems the borders loose the content and try to show what is behind it. It doesn't matter if I use the Intel or Nvidia GPUs or even a software rendered session, the same thing happens.

It doesn't seem to be a problem only with the image capture, the scripts that was already working doesn't work anymore when the images includes window borders, Sikuli doesn't recognize the borders of the windows in the screen its working on when trying to find images already saved that include borders.

These images was used mainly to recognize the window titles when it appears.

Question information

English Edit question
Sikuli Edit question
No assignee Edit question
Last query:
Last reply:
RaiMan (raimund-hocke) said : #1

--1. Sikuli 1.1.2 ???
... I do not know such a nightly build

--2. strange window border behaviour
... I am sorry, but I do not have any chance, to debug the problem.
This usually is a problem with the GUI/window manager.
Possible to try another window manager?

RaiMan (raimund-hocke) said : #3

at 1. LOL, LOLLLLL - sorry, you know my stuff better than I.

at 2. Yep, if you can afford the time, test another WM, just to assure, that the problem is with your current WM.
... but if you know that, it does not help.

A general test could be, what an internal screenshot looks like:
someRegion = Region(....)
img = capture(someRegion)

the capture is aved as testCapture.png in your current scriptfolder.
inspect it with some image viewer.

someRegion = Region(1, 1, 200, 200)
img = capture(someRegion)


[error] AttributeError ( 'unicode' object has no attribute 'saveInBundle' )





Ok. The capture function doesn't return an image object in my system, it return an unicode object with the path where the image was saved.

Looking at these images. The active window loose its borders and shows the content of another window (another terminal) behind it. The inactive window behind the terminal (a firefox browser window) shows the borders but again with the content of another firefox window that was behind the visible one. I tested with a lot of open windows overlapped and not maximized.

- The active visible window loose its borders
- The inactive visible window retains its borders
- In all windows the content was replaced with the content located in the same place of another window of the same running program (seems the first it found from the list of active windows)

About the wm, yes it seems a problem with the current one, as I was using it before with Linux Mint 17.3 with an older version of Cinnamon.

The problem is that I'm not using anything exotic, if I'm well informed I'm using the most used Linux distro with the most used wm with the latest version (18.2) based in a LTS release (Ubuntu 16.04).

(I don't know if Cinnamon is not the most used wm alone, I mean it's the default wm of the most used distro, so I suppose, the most used of that distro)

I will take a look at the code.

By now I can say that createScreenCapture() method from Javas Robot class do that. I have not coded in Java for years.

This is the simplest code that reproduces the problem:

import java.awt.Dimension;
import java.awt.Rectangle;
import java.awt.Robot;
import java.awt.Toolkit;
import java.awt.image.BufferedImage;
import javax.imageio.ImageIO;
import java.io.*;

public class Capture{
    public static void main(String args[]) {

        try {
            Dimension size = Toolkit.getDefaultToolkit().getScreenSize();
            Robot robot = new Robot();
            BufferedImage img = robot.createScreenCapture(new Rectangle(size));
            File myNewPNGFile = new File("ImageAsPNG.png");
            ImageIO.write(img, "PNG", myNewPNGFile);
        } catch(Exception e) {


RaiMan (raimund-hocke) said : #8

I close this question as solved, since I made the the problem a bug report.