[1.1.4] Mac: [error] checkMousePosition reports 1 pixel off

Asked by Chris Kosieracki on 2019-07-25

I was running the Sikulix build from 2018-12-14_08:11 without this problem. After upgrading to build 325, I am now getting many checkMousePosition errors when running in the IDE.
I have both Java and the tested app checked in the Privacy settings to allow them to control the computer. Any ideas?

Question information

English Edit question
Sikuli Edit question
No assignee Edit question
Last query:
Last reply:
Chris Kosieracki (cckozie) said : #1

Additional info:
I can't guarantee that the problem did not exist before as I upgraded in order to use findText(). It could be that the problem is related to findText() rather than something else in the upgrade.

Chris Kosieracki (cckozie) said : #2

I've created a small test script that shows the problem.
The actual script that I'm have the trouble with does not cause the cursor to fly around as much as this test script, but after doing some debugging I realized that the cursor error problem always occurred when clicking or double clicking something on the screen. That app is using "observe", and the cursor error sometimes occurs in an event and sometimes in the mainline.

import subprocess

mmd = Settings.MoveMouseDelay
Settings.MoveMouseDelay = 0.2

def image1Event(event):
    print('Event 1')
    if reg.exists(image1,0):

def image2Event(event):
    print('Event 2')
    if reg.exists(image2,0):

path = '/Applications/Google Chrome.app'
chrome = False
    subprocess.Popen(['open', '-a', path])
    chrome = True
    print "Unexpected error:", sys.exc_info()[0]
    print('Failed to start or set focus to ' + app)

image1 = Pattern("image1.png").similar(0.83)
image2 = Pattern("image2.png").similar(0.90)
tab1 = Pattern("tab1.png").similar(0.79)
tab2 = Pattern("tab2.png").similar(0.79)

urls = [',https://www.google.com','https://sikulix-2014.readthedocs.io/en/latest/']

tabs = True

if chrome:
    tReg = Region(0,23,1438,39)
    reg = Region(412,282,631,383)
    if not tabs:
        for url in urls:
            if exists(Pattern("1539898718565.png").similar(0.91),5):

    reg.onAppear(image1, image1Event)
    reg.onAppear(image2, image2Event)

    for i in range(0,10):
        if tReg.exists(tab1):
        if tReg.exists(tab2):

Settings.MoveMouseDelay = mmd

RaiMan (raimund-hocke) said : #3

what exactly are the messages you get?

Chris Kosieracki (cckozie) said : #4

The error message is:
[error] RobotDesktop: checkMousePosition: should be L[746,812]@S(0)
but after move is L[745,811]@S(0)
Possible cause in case you did not touch the mouse while script was running:
 Mouse actions are blocked generally or by the frontmost application.

In almost every situation, the cursor position is only off by 1 pixel either horizontally or vertically, or in this case, both.

RaiMan (raimund-hocke) said : #5

This looks like some rounding problems (current and expected position have different sources) may together with HiRes monitors.

Do you have a HiRes environment?

As a fix I have to add some "fuzzy logic" ;-)

Chris Kosieracki (cckozie) said : #6

I am running on a MacBook Air, display is 13.3-inch (2560 x 1600)

RaiMan (raimund-hocke) said : #7

I tested with the latest 1.1.4 build on my MacBook Pro Retina, which also has a display 13.3-inch (2560 x 1600).

My macOS is 10.14.5 and I tested both with Java 8 and Java 12.

Internally the screen size is reported and used as 1280 x 800, which is correct since a Retina display only boosts an internal pixel up to 4 pixels on the monitor.

With the following test I had no problems:
for i in range(10):
  print getLastMatch()
  print Mouse.at()

the image is something captured with the IDE in the bottom-right corner of the screen.

RaiMan (raimund-hocke) said : #8

if you further get the error messages, but you script works, you can switch off the error messages:
Settings.checkMousePosition = False

At the beginning of your script.

Can you help with this problem?

Provide an answer of your own, or ask Chris Kosieracki for more information if necessary.

To post a message you must log in.