← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #173203]: image found, but region location wrong

 

Question #173203 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/173203

    Status: Open => Answered

RaiMan proposed the following answer:
This runs perfectly (on my Mac, adapt it to Windows and your situation):

- have the Sikuli Q&A page open
- start the script
- open one of the answers
- the yellow beast appears and is matched

download source if you want: https://files.me.com/rhocke/6emk0r

I think it always makes sense to narrow the search region and it is
worth the coding effort, that might be necessary.

BTW: event.region is the observed region, a found match is event.match
(http://sikuli.org/docx/region.html#SikuliEvent)

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

import unittest

myVSRegion = App.focusedWindow()
# to really narrow down:
#  mySolExpRegion = myVSRegion.find("SolExpTitleBar.png").below()
#  Start debugging (solution explorer can move from left side to right side or vice versa
#  At break, which I am waiting for by waiting for the BPArrow.png, so already there is a catch 22
#myVSRegion.onAppear("BPArrow.png", BPArrowAppearHandler)

ab = App("Safari")
ab.focus()
aw = ab.window()
reg = aw.find("siklogo.png").below() 
# a column region below the top left Sikuli logo

class SobelFilterTest (unittest.TestCase):
    
    def setUp(self):
        print "in setUp:"
        reg.highlight(2)
        #self.BPRegion = None # not really needed

    def BPArrowAppearHandler(self, event):
        print "target appeared"
        self.BPRegion = event.match
        event.region.stopObserver()

    def test_SobelFilter1(self):
        print "in Test1" 
        # nArrow = Pattern("BPArrow.png")
        nArrow = Pattern("circle.png") # the yellow round edit button
        reg.onAppear(nArrow, self.BPArrowAppearHandler)
        reg.observe(300)
        self.BPRegion.highlight(3)

mySobelFilterTest = unittest.TestLoader().loadTestsFromTestCase(SobelFilterTest)
unittest.TextTestRunner(verbosity=2).run(mySobelFilterTest)

-- 
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.