Jump to content

# help with some autoit syntax please!

## Recommended Posts

ok, I have created a program that does sections of pixel searches.... basically, i check if a given section, another section a certain number of pixels above, and a third section a certain number of pixels below all have the same color in them. if that is true, then it continues to the next step.

what i would rather do is have it check individual pixels like so....

----------------------------------------------------------

| . |

| . |

| . |

-----------------------------------------------------------

above represents screen, if location(x,y) is blue, location(x,y+10) is blue, and location(x,y-10) is blue, then send "a".... this is just a sort of easier explaination of what I am looking to do... so basically pseudo code would go something like...

```\$color = 0xFF0000

for(int n=0, n<(number of horizontal values to check), n+(interval between horizontal checks))
{
\$var = PixelGetColor( n , y )
if Hex(\$var, 6)=\$color then
\$var2= PixelGetColor( n , y+10 )
if Hex(\$var, 6)=\$color then
\$var3= PixelGetColor( n , y-10 )
if Hex(\$var, 6)=\$color then

send"a"
endif
endif
endif
}```

so far thats what i think it would look like, please correct me on the pseudo if i messed up somewhere, i am still very new to autoit, and having quite a few problem... but i don't know how a "for" statement would go, i had so much trouble with the if statements. as you see i have multiple conditions to be met, but only know how to do it in the above way, please let me know if there is a way to do it in a way like: if(a=1)&&(b=2) then... done.

thanks everyone

#### Share this post

##### Share on other sites

```For \$n = \$x To \$y Step \$z
...
Next```

Generic construction, you can also use nested For...Next loop, one for \$x and one for \$y if you prefer to search top to bottom

#### Share this post

##### Share on other sites

Thanks! I now have a new problem... To test if the program works, I take a screenshot of my computer while the game is in a scenerio that everything should be executed... i then paste it as my desktop background... I then find the pixels I need to check... But there is a problem, When I open the flash game, the positions must be changed because nothing happens....

```Global \$Paused

HotKeySet("{END}", "TogglePause")
HotKeySet("{HOME}", "Terminate")

While 1
Sleep(100)
WEnd

Func TogglePause()
\$Paused = NOT \$Paused
While \$Paused

\$color = 0x990000
\$color2 = 0x000000

For \$i = 945 to 975 Step 5

\$var = PixelGetColor( \$i , 647 )
If \$color=\$var Then
Sleep(1)
\$var2 = PixelGetColor(\$i, 616)
If \$color=\$var2 Then
Sleep(1)
\$var3 = PixelGetColor(\$i, 589)
If \$color=\$var3 Then
MouseClick('left',\$i,616+5,1,0)
Sleep(100)
EndIf
EndIf
EndIf

Next

WEnd

EndFunc

Func Terminate()
Exit 0
EndFunc```

Thats what I have so far... I am wondering, what is the easiest way to code this, so that no matter where on the screen the flash game is, It will still work correctly... Thanks for any help!

#### Share this post

##### Share on other sites

You can try, \$hWnd = WinGetHandle('pfff', '') and use _WinAPI_GetClientRect(\$hWnd) and convert width and height to screen points and preform the check so it's relative to the \$nLeft or \$nTop etc... so you don't need to find where the window is located on the screen but rather it's offsets from the left or top.

Edited by Authenticity

#### Share this post

##### Share on other sites

thanks authenticity!

I have no clue about those commands, but I will try and look into them, and try and see if I can understand what to do. Thanks for the speedy advice.

#### Share this post

##### Share on other sites

Use DllStructCreate, DllStructGetPtr, DllStructSetData and DllStructGetData because this function return the tagRECT struct 'int;int;int;int'

## 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

×

• Wiki

• Back

• Git

## Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.