Jump to content
Sign in to follow this  
Cornflake

Need Help with detecting color and using arrays

Recommended Posts

So this is my code right here...

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

$1 = x

$2 = 2x

...

$39 = 39x

$40 = 40x

;The X's=A File

Sleep(10000)

MouseClick("Left",350,237)

Sleep(100)

Send($1, 1)

Send("{ENTER}")

Sleep(8000)

MouseClick("Left",65,130)

Sleep(8000)

MouseClick("Left",350,237)

Sleep(100)

Send($2, 1)

Send("{ENTER}")

Sleep(8000)

MouseClick("Left",65,130)

Sleep(8000)

...

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

That last part goes on 40 times. I want to condense it using an array that doesnt randomly choose 1-40 but picks 1-40 in order. HOw would I do this?

Also, I want to change the first sleep into a color recognition thing instead of just randomizing it by time, because Im dealing with the internet with this and we all know the internet doesnt load exactly at the same time every time.

So I want it to check an area...or a pixel(Dont know how it works) for a color (Green or grey, cant recall right now) and if its not one of those...keep waiting, if it is the color, then go to the designated coordinate and click.

I tried searching but couldnt really find much...I did on arrays but my comprehension on how they work is low.

Thanks in advance for any help, hope I explained it in enough detail.

Share this post


Link to post
Share on other sites

That last part goes on 40 times. I want to condense it using an array that doesnt randomly choose 1-40 but picks 1-40 in order. HOw would I do this?

<{POST_SNAPBACK}>

StringSplit() /w a For...Next loop.

Also, I want to change the first sleep into a color recognition thing instead of just randomizing it by time, because Im dealing with the internet with this and we all know the internet doesnt load exactly at the same time every time.

So I want it to check an area...or a pixel(Dont know how it works) for a color (Green or grey, cant recall right now) and if its not one of those...keep waiting, if it is the color, then go to the designated coordinate and click.

<{POST_SNAPBACK}>

PixelGetColor() With If...Else...EndIf Statement.

qq

Share this post


Link to post
Share on other sites

The PixelGetColor() worked flawlessly! Im so excited.

However, Im not quite sure I understand how the StringSplit() command works.

Does it work like this...

$phrase = StringSplit("File1,File2,ect,",",")

Then I put that in my For next loop section (Still confused on that aswell)

Thanks for the PixelGetColor!!!!!

Share this post


Link to post
Share on other sites

Dim $File[41]

$File[1] = FileX
$File[2] = File2X
Ect
Ect
$File[39] = File39X
$File[40] = File40X

$pixel = PixelGetColor( 420 , 150 )

If $pixel > -1 Then
MouseClick("Left",350,237)
EndIf

for $file[1] = 1 to 40 Step +1


MouseClick("Left",350,237)
Sleep(100)
Send("$file[1]" ,1)
Send("{ENTER}")
Sleep(7000)
MouseClick("Left",60,125)
Sleep(10000)

Next

This is what I came up with, but its not working too well...Im kinda stuck :(

Im going to be changing all those Sleeps in the loop into PixelGetColors, but I left them as sleeps for the sake of simplicity.

Edited by Cornflake

Share this post


Link to post
Share on other sites

change >>>> for $file[1] = 1 to 40 Step +1

to >>>>> for $index = 1 to 40

and

change >>>> Send("$file[1]" ,1)

to >>>>> Send("$file[$index]" ,1)

EDIT: as noted by Burrup, should be:

Send($file[$index] ,1) > Take out the qoutation marks.

Doh << does that translate well?

Edited by herewasplato

[size="1"][font="Arial"].[u].[/u][/font][/size]

Share this post


Link to post
Share on other sites

change >>>> for $file[1] = 1 to 40 Step +1

to >>>>> for $index = 1 to 40

and

change >>>> Send("$file[1]" ,1)

to >>>>> Send("$file[$index]" ,1)

<{POST_SNAPBACK}>

Is this because I need full works for my variable?

Because I noticed it was spewing out parts of my other variables for some reason. That really confused me.

EDIT: It didnt work :( It is printing this: for $index = 1 to 40ile[$index]

Edited by Cornflake

Share this post


Link to post
Share on other sites

.....EDIT: It didnt work :( It is printing this: for $index = 1 to 40ile[$index]

<{POST_SNAPBACK}>

Even with my stupid error, I do not see how the script could put out:

for $index = 1 to 40ile[$index]

Could you post your latest verision of code please?


[size="1"][font="Arial"].[u].[/u][/font][/size]

Share this post


Link to post
Share on other sites

Even with my stupid error, I do not see how the script could put out:

for $index = 1 to 40ile[$index]

Could you post your latest verision of code please?

<{POST_SNAPBACK}>

It was the quotation marks! I took them out last night and it worked and I forgot to mention it.

Is an If statement a loop? Because I want to use something like an if statement to check if it can go on. I have a pixelcolor check and I want it to check every 1000ms or so if anything in the area has changed...but its checking and if it hasnt then its going on to the next line of code.

Share this post


Link to post
Share on other sites

You can put an If Statement inside a Loop.

While 1
   If ... Then
     ; blah
   Else
     ; blah
   EndIf
Wend

qq

Share this post


Link to post
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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...