kronoss Posted July 16, 2011 Share Posted July 16, 2011 (edited) i am new here and wanted some direction on how or if its possible to find a color(i have that) and see what colors are around it and move it to where the same color are all next to each other? Ex. i want all the "1" in vert. lines the rest do not matter. i can move diagonally only 11231233 33322122 12233112 22111333 21233321 please and thank you for your help Edited July 16, 2011 by kronoss Link to comment Share on other sites More sharing options...
JohnOne Posted July 16, 2011 Share Posted July 16, 2011 see what colors are around it and move it to where the same color are all next to each otherPlease add some context to this.And before you do, it will be a good Idea to read the forum rules. 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...
kronoss Posted July 16, 2011 Author Share Posted July 16, 2011 alright i read the rules and what i need is acceptable to talk about here. more detail. i have files that are highlighted in different colors and i need to be able to line them up and when i say diagonally its cuz they have a bit of an offset and are not in straight lines like my ex. some are a little higher and some are lower. and if i drag them into another one the swap and i would much prefer to automate it i have almost every thing done except for how to start at the top right and go down and to the left if you could help with that it would be amazing im using the pixelsearch function Link to comment Share on other sites More sharing options...
monoscout999 Posted July 16, 2011 Share Posted July 16, 2011 i can`t understand you, post a snippet(working) and told us what you want the program have to do. Link to comment Share on other sites More sharing options...
kronoss Posted July 16, 2011 Author Share Posted July 16, 2011 (edited) i want it to search for pixels starting from the top right to bottom left scanning from top to bottom instead of from left to right $loop = 1 HotKeySet("1" , $loop=1) HotKeySet("2" , $loop = 0) MouseClick("Left",400,400,1) Opt("mouseCoordMode",1) While $loop = 1 PixelSearch(0,0,800,600,0xCBD96E) If not @error Then Exit EndIf $cord = PixelSearch(800,600,0,0,0xD0B64F) if Not @error then $x = $cord[0] $y = $cord[1] MouseMove($x, $y) Call("down") Call("up") EndIf WEnd Func down() $dl = PixelSearch($x -60,$y+10,$x -20,$y+60, 0x9B821F) if Not @error Then MouseClickDrag("Left", $x,$y,$x-40,$y+40) EndIf EndFunc Func up() $ul = PixelSearch($x -60,$y-40,$x -20,$y, 0x697A4D) if Not @error Then MouseClickDrag("Left", $x,$y,$x-40,$y-40) EndIf EndFunc Edited July 16, 2011 by kronoss Link to comment Share on other sites More sharing options...
monoscout999 Posted July 16, 2011 Share Posted July 16, 2011 (edited) left - left coordinate of rectangle. top - top coordinate of rectangle. right - right coordinate of rectangle. bottom - bottom coordinate of rectangle. color - Colour value of pixel to find (in decimal or hex).this is what PixelSearch Help says... so here PixelSearch(left = 800, top = 600, right = 0, bottom = 0,color = 0xD0B64F) ...you are passing 600 as your top side and 0 like you bottom side PixelSearch search always from what "top" parameter says to "bottom" invert the values to make it search in different directions... EDIT: Dont create new threads for every question about the same topic Edited July 16, 2011 by monoscout999 Link to comment Share on other sites More sharing options...
kronoss Posted July 16, 2011 Author Share Posted July 16, 2011 (edited) EDIT: Dont create new threads for every question about the same topicthe first one was not supposed to be about this topic it was just the theory in general as well if it was possible this one was for asking bout this topic. but duly noted EDIT: i tried 0,800,600,0 but that wont work either it does not move at all if i type that Edited July 16, 2011 by kronoss Link to comment Share on other sites More sharing options...
monoscout999 Posted July 16, 2011 Share Posted July 16, 2011 (edited) I checked and PixelSearch works with every direction... maybe the color is not there, try adding a shade variation value. I left here my tests. try it. expandcollapse popup#include <windowsconstants.au3> $hGui = GUICreate("My PixelSearch() test", -1, -1, -1, -1, $WS_POPUP) GUISetBkColor(0) GUICtrlCreateGraphic(10, 10, 10, 10) GUICtrlSetBkColor(-1, 0xff0000) GUICtrlCreateGraphic(380, 10, 10, 10) GUICtrlSetBkColor(-1, 0xff0000) GUICtrlCreateGraphic(10, 380, 10, 10) GUICtrlSetBkColor(-1, 0xff0000) GUICtrlCreateGraphic(380, 380, 10, 10) GUICtrlSetBkColor(-1, 0xff0000) GUISetState() $Rect = WinGetPos($hGui) ; Getting the coord from the Window. $left = $Rect[0] ; saving the coords in variables. $top = $Rect[1] $right = $Rect[2] + $Rect[0] ; Width + left = Right $bottom = $Rect[3] + $Rect[1] ; Height + Top = Bottom ToolTip("wait 3 sec") Sleep(3000) ToolTip("now we gonna use pixelsearch in every direction aviable" & @CRLF & "And we gonna move the mouse to check the pixel that the funcion found") Sleep(6000) ToolTip("Pixelsearch($left,$top,$right,$bottom,0xff0000)") Sleep(2000) $coord = PixelSearch($left, $top, $right, $bottom, 0xff0000) If Not @error Then MouseMove($coord[0], $coord[1]) Sleep(3000) ToolTip("Pixelsearch($left,$bottom,$right,$top,0xff0000)") Sleep(2000) $coord = PixelSearch($left, $bottom, $right, $top, 0xff0000) If Not @error Then MouseMove($coord[0], $coord[1]) Sleep(3000) ToolTip("Pixelsearch($right,$top,$left,$bottom,0xff0000)") Sleep(2000) $coord = PixelSearch($right, $top, $left, $bottom, 0xff0000) If Not @error Then MouseMove($coord[0], $coord[1]) Sleep(3000) ToolTip("Pixelsearch($right,$bottom,$left,$top,0xff0000)") Sleep(2000) $coord = PixelSearch($right, $bottom, $left, $top, 0xff0000) If Not @error Then MouseMove($coord[0], $coord[1]) Sleep(3000) EDIT: About finding nearest colors. you need to think a while. Func _NearestColors($aCoord, $color) If IsArray($aCoord) Then Local $aResult[1][2] Local $index = 0 For $x = $aCoord[0] - 1 To $aCoord[0] + 1 For $y = $aCoord[1] - 1 To $aCoord[1] + 1 If PixelGetColor($x, $y) = $color Then ReDim $aResult[$index + 1][2] $aResult[$index][0] = $x $aResult[$index][1] = $y $index += 1 EndIf Next Next ;~ _ArrayDisplay($aResult) Return $aResult Else SetError(1, 0, False) EndIf EndFunc ;==>_NearestColors Edited July 16, 2011 by monoscout999 Link to comment Share on other sites More sharing options...
kronoss Posted July 17, 2011 Author Share Posted July 17, 2011 alright thanks and if i need to skip over one how would i do that i have tried a few methods including checksums, and pixelgetcolor but none worked the provblem is when i have a 1 that cant move cuz all thats to the left are ones how can i move to the next? ex ABCDEFG 0000100 0000100 0000110 0000100 0000010 the problem lies in row "F" where i have a 1 that can not move cuz of other 1's and so the pixelsearch will not move past that one. but i need it to jusp it and move to the nex 1 in that row? Link to comment Share on other sites More sharing options...
monoscout999 Posted July 17, 2011 Share Posted July 17, 2011 Idont understand you. sorry Link to comment Share on other sites More sharing options...
kronoss Posted July 18, 2011 Author Share Posted July 18, 2011 (edited) Idont understand you. sorry in one row i have two files that i need to move but the top file only has those of the same color around it so it will not move. how can i skip over this file and move to the next one of that color in the row?Edit i may have it but how do i use endFunc as a result of an if then statement? when i try it ends the func no matter whet Edited July 18, 2011 by kronoss Link to comment Share on other sites More sharing options...
kronoss Posted July 18, 2011 Author Share Posted July 18, 2011 (edited) my new code to check for files in collms from right to left and move them left. i also am trying to add my file skipping func (func Check ) but it is not working any hints? i cant get it to work and i do not know what is wrong! very annoying expandcollapse popup$loop = 1 HotKeySet("1" , $loop=1) HotKeySet("2" , $loop = 0) MouseClick("Left",400,400,1) Opt("mouseCoordMode",1) $x =0 $y =0 $cord = 0 $top = 160 $check = 0 Call("Main") Func Main() While $loop = 1 PixelSearch(0,0,800,600,0xCBD96E) If not @error Then Exit EndIf $check = PixelChecksum(25,$top,485,520) Call("Srow1") Call("up") Call("down") WEnd EndFunc Func down() $dl = PixelSearch($x -60,$y+10,$x -20,$y+60, 0x9B821F) if Not @error Then MouseClickDrag("Left", $x,$y,$x-40,$y+40) EndIf EndFunc Func up() $ul = PixelSearch($x -60,$y-40,$x -20,$y, 0x697A4D) if Not @error Then MouseClickDrag("Left", $x,$y,$x-40,$y-40) EndIf EndFunc Func Srow1() $cord = PixelSearch(385,$top,485,520,0xD0B64F) If @Error Then Call("Srow2") EndIf if Not @error then $x = $cord[0] $y = $cord[1] MouseMove($x, $y) EndIf EndFunc Func Srow2() $cord = PixelSearch(345,$top,385,520,0xD0B64F) If @Error Then Call("Srow3") EndIf if Not @error then $x = $cord[0] $y = $cord[1] MouseMove($x, $y) EndIf EndFunc Func Srow3() $cord = PixelSearch(305,$top,345,520,0xD0B64F) If @Error Then Call("Srow4") EndIf if Not @error then $x = $cord[0] $y = $cord[1] MouseMove($x, $y) EndIf EndFunc Func Srow4() $cord = PixelSearch(265,$top,305,520,0xD0B64F) If @Error Then Call("Srow5") EndIf if Not @error then $x = $cord[0] $y = $cord[1] MouseMove($x, $y) EndIf EndFunc Func Srow5() $cord = PixelSearch(225,$top,305,520,0xD0B64F) If @Error Then Call("Srow6") EndIf if Not @error then $x = $cord[0] $y = $cord[1] MouseMove($x, $y) EndIf EndFunc Func Srow6() $cord = PixelSearch(185,$top,225,520,0xD0B64F) If @Error Then Call("Srow7") EndIf if Not @error then $x = $cord[0] $y = $cord[1] MouseMove($x, $y) EndIf EndFunc Func Srow7() $cord = PixelSearch(145,$top,185,520,0xD0B64F) If @Error Then Call("Srow8") EndIf if Not @error then $x = $cord[0] $y = $cord[1] MouseMove($x, $y) EndIf EndFunc Func Srow8() $cord = PixelSearch(105,$top,145,520,0xD0B64F) If @Error Then Call("Srow9") EndIf if Not @error then $x = $cord[0] $y = $cord[1] MouseMove($x, $y) EndIf EndFunc Func Srow9() $cord = PixelSearch(65,$top,105,520,0xD0B64F) If @Error Then Call("Srow10") EndIf if Not @error then $x = $cord[0] $y = $cord[1] MouseMove($x, $y) EndIf EndFunc Func Srow10() $cord = PixelSearch(25,$top,65,520,0xD0B64F) If @error Then Call("Check") EndIf if Not @error then $x = $cord[0] $y = $cord[1] MouseMove($x, $y) EndIf EndFunc Func Check($top) if PixelChecksum(25,$top,485,520) == $check Then $top = ($y - 40) Return $top ElseIf PixelChecksum(25,$top,485,520) <> $check Then $top = 160 Return $top EndIf Call("Main") EndFunc Edited July 18, 2011 by kronoss 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