GodForsakenSoul Posted November 1, 2009 Share Posted November 1, 2009 long time ago i stumbled upon a different language. a crappy language which, while did do what i asked, didn't allow nice things like running files as standalone programs or making custom guis exactly as you wanted... and many other options probably. what it did had, however, was the option to change a longass command into a short $x thing. i'd like to know how it can be done in autoit. and if not exactly into $x, then to the shortest possible thing. i'm working with image recognition right now, and i don't want a long line of "if pixelgetcolor(x,y)=xxx and pixelgetcolor(x1,y1)xxx1 and...". i'm talking large objects like 25x25 points of reference. Link to comment Share on other sites More sharing options...
Authenticity Posted November 1, 2009 Share Posted November 1, 2009 It depends how your script is structured. Many things can be shorten but it requires to identify the widely used commands around the script that are more appropriate within a function or other conditional structure. Hollow words, but a few lines of code can help here. Link to comment Share on other sites More sharing options...
GodForsakenSoul Posted November 1, 2009 Author Share Posted November 1, 2009 i don't have an exact peice of code, but the idea is as follows: if pixelgetcolor(x,y)=xxx and <repeat a good few dozen times> then mousemove(x,y) mouseclick("left") elseif pixelgetcolor(x,y)=xxx1 and <again, repeat alot> then call(Refill) that's the code i'm planning i'm a gist. minus the upcoming debugging and losing retarded bugs such as 1 pixel offset Link to comment Share on other sites More sharing options...
CyberneticSoldier Posted November 1, 2009 Share Posted November 1, 2009 (edited) I think functions can help you here... then you have one long line. and instead of doing "if xx and xx and xx" you could also write a loop to do that. Maybe a few more lines vertically, but a lot less characters and more readable. I don't know if the coordinates you want to check allow you to do that though... Edited November 1, 2009 by CyberneticSoldier Link to comment Share on other sites More sharing options...
Authenticity Posted November 1, 2009 Share Posted November 1, 2009 (edited) You need to use arrays for coordinates and maybe for colors and loop the array coordinates against the colors, for example: Local $avCoords[3][2] = [[20, 30], [110, 120], [0, 200]] Local $avClrs[5] = [0xABCDEF, 0xADBEEF, 0x112200, 0xFF20, 0xC33F00] For $i = 0 To UBound($avCoords)-1 If PixelGetColor($avCoords[$i][0], $avCoords[$i][1]) <> $avClrs[0] ExitLoop Next If $i < UBound($avCoords) Then ; Run another loop against different color for different times Else Refill() EndIf You can shorten this code more by nesting looping say $i for coordinates and $j for number of colors. You can make it a function but it'll make sense if the same function get called by several or more points in your code. Edited November 1, 2009 by Authenticity Link to comment Share on other sites More sharing options...
nikink Posted November 3, 2009 Share Posted November 3, 2009 While the arrays method is probably better overall, to answer your posted question you could shorten PixelGetColor() by simply wrapping another function around it. Func pgc($x, $y) Return PixelGetColor($x, $y) EndFunc 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