[1.1.4 Jython] Region().highlight() blocks Screen().click() --- solution

Asked by Dirk Schiller on 2019-02-09

********************* solution

since highlight() (no parameters) is a toggle function, you either have to close the highlight by another highlight() or use the self-closing highlight with a time parameter.
see: https://sikulix-2014.readthedocs.io/en/latest/region.html#Region.highlight

-----------------------------------------------------------------------------------

Script:
=====
import os, sys, time
sys.path.append(os.path.dirname(os.path.realpath(__file__)) + '/sikulixapi.jar')

from org.sikuli.script import App
from org.sikuli.script import Screen
from org.sikuli.script import Pattern
from org.sikuli.script import Finder
from org.sikuli.basics import Settings
from org.sikuli.basics import Debug
from org.sikuli.script import Mouse
from org.sikuli.script import Location

class Sikuli:

    def __init__(self):
        Mouse.setMouseMovedAction(0)
        Settings.Highlight = True # Fires two Times per Action
        Settings.MinSimilarity = 0.95
        Settings.setShowActions(False) # Doesn't show any Effect
        self.screen = Screen()
        # Mouse.setMouseMovedHighlight(True)

    def app(self, app):
        try:
            self.app = App(app)
        except:
            pass
        finally:
            self.app = App(app)

    def app_open(self):
        self.app.open()

    def app_close(self):
        self.app.close()

    def move_offset(self, x, y):
        Mouse.move(x, y)

    def move(self, x, y):
        loc = Location(x, y)
        Mouse.move(loc)

    def click_image(self, image, timeout=5):
        self.move(0, 0)
        reg = self.screen.wait(image, timeout)
        reg.highlight() # Disable the Click Action; Clicks doesn't come trough
        self.screen.click(image)

Versions:
=======
Jython 2.7.0
SikuliXApi.jar Version 1.1.4
Windows 10

Question:
========
The reg.highlight() Line highlights the recognized Image but prevent the self.screen.click(image). The Mouse Cursor moves to the Position and I am pretty sure that it also invoke a Click but I guess the Highlight Method has an Overlay which is HitTestVisible so the Mouse can not click trough it. Is there a way to click through the Highlighted Region ?

Question information

Language:
English Edit question
Status:
Answered
For:
Sikuli Edit question
Assignee:
No assignee Edit question
Last query:
2019-02-09
Last reply:
2019-02-09
Dirk Schiller (dschiller) said : #1

Possible Solution:
==============

reg.highlight(1)

Explanation:
==========
Seems the Region().highlight() Method doesn't wait if the Method Signature is empty. Otherwise it will wait the exact Seconds from the Signature.

Can you help with this problem?

Provide an answer of your own, or ask Dirk Schiller for more information if necessary.

To post a message you must log in.