adrian-evo / robotframework-sikulixlibrary

The all new, modern, SikuliX Robot Framework library for Python 3.x, based on JPype or Py4J Python modules.
MIT License
22 stars 4 forks source link

How to access coordinates of previous match? #10

Open superhans2 opened 2 weeks ago

superhans2 commented 2 weeks ago

I can access the coordinates of a previous match using: lib.appMatch.x and lib.appMatch.y however, this will only work if I first run lib.region_highlight(1, useLastMatch=True)

If I do not run this command, the region coordinates being referred to are the screen (at 0,0)

This behaviour works, but I don't like the fact that it is stateful. Is this a bug or is there an alternative method that is intended to be used?

Many thanks

adrian-evo commented 2 weeks ago

This is because Region getLastMatch() is not implemented (not all Region methods are implemented here, but only relevant ones), and highlight is saving last match for other purposes than accessing the coordinates (this is a side effect and it works as workaround). However, the method can be implemented in sikuliregion file very similar with e.g. def region_getAutoWait(self), and instead use region_getLastMatch().