ss
New Member
Posts: 3
|
Post by ss on Jun 7, 2018 18:19:52 GMT
In the app I have a button, the position of which never changes. How to check its availability without using Region: find()? Is it possible to create a pattern with the location? For checking without searching it all over the screen
|
|
|
Post by Exilereven on Jun 8, 2018 4:41:53 GMT
Have you tried use targetOffset, then checking the color of only that location? Use the color as like a on off switch. So you can use your same pattern and add on :targetOffset (x,y) to the end. PatternX and y are your own coords. Example. (Setup your object) OBJ = {} OBJ.dot = { location = Location(0, 0), color = { 248,46,79 }, diff = {10,10,10}, } local pattern = Pattern("red_dot.png"):targetOffset(-40, 40) --Will locate png, then move left 40 and down 40 for target location for color check local target_loc = region:getLastMatch():getTarget() OBJ.dot.location = target_loc Then just do a color compare with the OBJ.dot.location NOT TESTED just a good starting point I think.
|
|
|
Post by Acera Dryd on Jun 8, 2018 8:06:03 GMT
Have you tried something like that:
testRegion = Region(100,200,20,30) --x,y,width,height
if testRegion:exists(pattern) then --or with searchduration: testRegion:exists(pattern, 2) doSomething1() else doSomething2() end That looks only in the testRegion, if the pattern exists. It's a really fast version and should use everywhere in your code, because searching the full screen is very slow and can lead to failures.
|
|