Jump to content

shortening commands


Recommended Posts

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

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

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 by CyberneticSoldier
Link to comment
Share on other sites

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 by Authenticity
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...