Justchris25 Posted April 11, 2011 Share Posted April 11, 2011 (edited) Alright, this will kind of be a lengthy question but basically I'm trying to search for a top point of an arrow. regardless of which way the arrow is facing and move the mouse to it. This is just for fun with no real purpose except learning. I'm doing this in mspaint so the search area is not very big. Using lines I draw an arrow. The arrow has a tip 2 sides and then the bottom. I know the distance between the top to each side, and the top to the bottom. Right now it takes way to long to search because each point is using a for loop. And its also not finding the arrow tip. Heres an example of my code. Any help would be awesome this is just mock code. Id have to completely re-write my code to post which I wouldnt mind doing if someone was willing to help. But for now this is just an idea. for $sAreaX = 60 to 500 ;sets search area x, y for $sAreaY = 60 to 500 $point1 = pixelgetcolor($sAreaX, $sAreaY) ;searches for the first black point if $point1 = 0x00000 then ; for $x2 = $sAreaX - $lineLength to $sAreaX + $lineLength for $y2 = sAreaY - $lineLength to sAreaY + $lineLength $point2 = pixelgetcolor($x2, $y2) if $point2 = 0x00000 and _lineLength(sAreaX, sAreaY, $x2, $y2)= _ = $orginalLength then and so on... for each of the 4 points. So it takes forever and essentially doesnt work. Sorry if thats confusing. Any help would be awesome. Edited April 11, 2011 by Justchris25 Link to comment Share on other sites More sharing options...
JohnOne Posted April 11, 2011 Share Posted April 11, 2011 (edited) In the 4 years you been here, did you hear about pixelsearch? EDIT: Sorry, that was a bit of a lousey answer that. Think about using pixel search to find the first black = you have a top area to work with reverse the search to find the bottom. Since you know how big your arrow is, with some math you can roughly determine its left and right You now have a smaller area to begin finding your point. Edited April 11, 2011 by JohnOne AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Justchris25 Posted April 11, 2011 Author Share Posted April 11, 2011 That was what I was originally trying to do.. But then switched to getcolor. Thanks for the input though. I'll go back and reattempt it. Link to comment Share on other sites More sharing options...
JohnOne Posted April 12, 2011 Share Posted April 12, 2011 how many directions does your arrow point? If its lefr right up down, you might want to localize your area using pixelsearch and search it for the 4 possible checksums you might have. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Justchris25 Posted April 15, 2011 Author Share Posted April 15, 2011 (edited) Well this doesn't seem to be working either. Here's what I've got so far..Any help would be awesome. image - code - expandcollapse popup;--top point $x1 = 345 $y1 = 167 ;--left point $x2 = 302 $y2 = 234 ;--right point $x3 = 393 $y3 = 230 ;--calculates the distance between each point $llength = _lineLength($x1, $y1, $x2, $y2) $rLength = _lineLength($x1, $y1, $x3, $y3) $ltorLength = _lineLength($x2, $y2, $x3, $y3) $point1 = pixelsearch(68, 50, 694, 432, 0x000000) while $leftLength <> $llength ;searches left side if @error Then ContinueLoop elseif not @error then for $sAreaX = $point1[0] - $llength+1 to $point1[0] + $llength+1 for $sAreaY = $point1[1] - $llength+1 to $point1[1] + $llength+1 $lPoint = pixelgetcolor($sAreaX, $sAreaY) if $lPoint = 0x000000 then $leftLength = _lineLength($point1[0], $point1[1], $sAreaX, $sAreaY) if $leftLength = $llength Then mousemove($point1[0], $point1[1]) mousemove($sAreaX, $sAreaY) tooltip("FOUND!!", 400, 400) sleep(5000) for $sAreaX = $point1[0] - $rLength+1 to $point1[0] + $rLength+1 for $sAreaY = $point1[1] - $rLength+1 to $point1[1] + $rLength+1 $rPoint = pixelgetcolor($sAreaX, $sAreaY) if $rPoint = 0x000000 then $RightLength = _lineLength($point1[0], $point1[1], $sAreaX, $sAreaY) if $RightLength = $rLength Then mousemove($point1[0], $point1[1]) mousemove($sAreaX, $sAreaY) tooltip("FOUND!!", 400, 400) sleep(5000) exit Else ContinueLoop EndIf EndIf Next next Else ContinueLoop EndIf endIf Next next endIf $point1 = pixelsearch(68, 50, 694, 432, 0x000000) wend func _lineLength($x1, $y1, $x2, $y2) $num = abs(($x1-$x2)^2)+abs(($y1 - $y2)^2) $llength = sqrt($num) $llength = round($llength, 0) return $llength EndFunc Edited April 15, 2011 by Justchris25 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now