|
Post by vampiredbr9 on Jan 27, 2017 16:34:33 GMT
USEFUL FOR SCRIPT DEVELOPERS STRUGGLING WITH THE MATH... OR WANT A MORE PRECISE REGION, FOR FASTER IMAGE RECOGNTION I have created a very short piece of code, which if I may say so myself is pretty awesome. First you run it, select the compare dimension you have inside the app you are scripting, then tap the two opposite corners of the area you want a region. What is unique about this, is that the script scales the region to the compare dimension of your other script, meaning you don't have to do any complicated calculations, or guesswork Source Code: (if you want to know how it works) dialogInit() addTextView("Compare Dimension of your other script:") addEditNumber("compare", 600) newRow() dialogShow("Region Finder V1.0") Settings:setCompareDimension(true, compare) toast("Touch First Location") local action, one, touchTable = getTouchEvent() wait(1) toast("Touch Second Location") local action, two, touchTable = getTouchEvent() onex = one:getX() oney = one:getY() twox = two:getX() twoy = two:getY() width = twox - onex height = twoy - oney myRegion = Region(onex, oney, width, height) myRegion:highlight() wait(2) print("[MyRegionName] = Region("..onex..", "..oney..", "..width..", "..height..")") dialogInit() addEditText("RegionName", "[MyRegionName] = Region("..onex..", "..oney..", "..width..", "..height..")") dialogShow("Copy and paste region")
Here's the link to download: www.mediafire.com/download/cjvv3ca4k0vv9k4
|
|
roko
New Member
Posts: 3
|
Post by roko on Jul 2, 2020 12:15:58 GMT
I just stumbled upon this script, because I wanted to code something very similar.
I hope that you already fixed the flaw with the "Copy and paste" part. The way the script is right now it will save the data from the first use in that field and then stay this way, although the variables change. To fix that you must us removePreference("RegionName") at the start of your 2nd dialogInit().
Hope that will help others to use this nice script.
best regards
|
|
ATG
Junior Member
Posts: 79
|
Post by ATG on Aug 14, 2020 22:08:31 GMT
this should move to script skills section. i wish this forum can have tags. if it is about while loop. any users can click on that, to look into it to learn. its like good answers are all over the places.
|
|