← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #272154]: [1.1.0] Is there a way to integrate a (background) observer with wheel()?

 

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

    Status: Open => Answered

RaiMan proposed the following answer:
this works with 1.1.0: (tested on OS X 10.11)

switchApp("myApp") # bring the app to front
r = App.focusedWindow() # the search area
imgStop = "imgStop.png" # the stop image to wait for

stopAppeared = r.onAppear(imgStop) # no handler needed, since observing stops with first appearance
# save a reference to the event
r.observeInBackground(FOREVER) # start observation
while not r.isObserving(): wait(0.3) # hack currently needed, to use isObserving()

r.hover() # move mouse to a point, where wheel is accepted
while r.isObserving(): # until observing is stopped
  wheel(WHEEL_UP, 10) # wheel (might be WHEEL_DOWN on Windows)
  wait(1)

... and this as a goody on top ;-)
m = r.getEvent(stopAppeared).getMatch()
hover(m)
m.highlight(2)

-- 
You received this question notification because your team Sikuli Drivers
is an answer contact for Sikuli.