Jump to content

count if color


Recommended Posts

hi to all;

 I have 2 loops; loop(1) go through a table line by line (max number of lines is 23; using for $i=1 to 23); distance between each line is 20; I am concerned in 3 columns of my table; Loop2 repeat  loop (1) 100 time (using For $r=1 to 100)

I use the following to go through lines of table (Loop1) depending on column 3

for $L=1 to 23;  $L=Line number

A)) Column 3 contain 3 color possibilities 1=red; 2=black; 3=white; X coordinate=871

$yLine=280+($L*20);  the Y coordination of the first line is 300; so 300-20 is 280

MouseMove(871,$yLine) ; X coordinate of coulmn3=871

local $color3=PixelGetColor(871,$yLine);

if $color3=6684730 or $color3=6160437 then ;  if color is black do function1

function1()

endif

if $color3=16777215 or $color3=13143889 then  ; the $color3=white; no data in line

MsgBox("","You reach the last line","Exit For $i Loop start from $i=1",2); must exit Loop1 and start new round

                ContinueLoop(2);?????

EndIf

if $color3=16711738 or $color=16252981 then  ;$color3 is red;  go to coulmn2

MsgBox("","Color 3 is","Red",1);must skip line to the next without exiting loop1(lines)

ContinueLoop(1); ??? not sure is it this code necessary

EndIf

B))  Column 2 contain 3 color possibilities 1=black; 2=white; 3=grey; X coordinate=660

Action1: is taken (function 1() ) only if color in column 3 is black and in column 2 is also black  

Action2: is taken (function 2() ) only if color in column 3 is black and in column 2 is white or grey   

MouseMove(660,$yLine);

local $color2=PixelGetColor(660,$yLine);

if $color2=6684730 or $color2=6160437 then MsgBox("","Color 2 s","Black",1);

((if $color3=" Black " And $color2=" Black" then function1()   ))

((if $color3="Black" And ($color2="White" or $color2="grey")  then function2()   ))

I am not sure that the last 2 lines are O.K!!

C)) Column 1 have 2 possibilities 1=red; 2=blue; X coordinate=28; I need to count how many lines are red, and how many  are , this column using the loop

 MouseMove(28,$yLine);

local $color1=PixelGetColor(28,$yLine)

if $color1=14170419  then $Type="Sell"  ;color1="red"

if $color1=24225  then    $Type="buy" ;$coler1="green"

I need to count red and blue Lines in this column using the loop; I couldn't do that;

Any advice, help is highly appreciated

3.png

Link to comment
Share on other sites

dear Autoit forum;

I have only two colors in column 1; $color1=14170419   ;"red"; and  $color1=24225 ;"blue"

For $L=1 to 19

$yLine=280+($L*20);  the Y coordination of the first line is 300; so 300-20 is 280

MouseMove(28,$yLine);

local $color1=PixelGetColor(28,$yLine)

 $color1=14170419   ;"red"

 $color1=24225  ;"blue"

next

I need to count red and blue Lines in this column using the loop; I couldn't do that;

Any advice, help is highly appreciated

4.jpg

Link to comment
Share on other sites

Sorry Jos; may be I have comuncation problm english is not my first laguge, so if you look at the attached file it may be easir, I have one topic is it possble to count in each line of the coulmn thee red color, Thancks in advance

 

Link to comment
Share on other sites

search for bitblt in the forum it will help you analysing colorbits quicker.

 

But to start slow are you just looking for if ...then ?
I would just start to see what happens if you do for $yLine=280 to 680 to see which values you get

For $L=1 to 19
    $yLine=280+($L*20);  the Y coordination of the first line is 300; so 300-20 is 280
    MouseMove(28,$yLine);
    
    local $color1=PixelGetColor(28,$yLine)
    consolewrite($color1)

    if ($color1=14170419) then
        consolewrite("red")
    endif
    if ($color1=24225) then
        consolewrite("blue")
    endif
    
next

 

Link to comment
Share on other sites

thanks junkew for your help, I usually like using for next loop; results are :24225blue24225blue24225blue24225blue24225blue24225blue24225blue14170419red24225blue14170419red24225blue24225blue24225blue24225blue24225blue24225blue24225blue14170419red24225blue

so how to count blue and red??

 

Link to comment
Share on other sites

Hi @Majedz.

I guess you want to count the number of red and blue lines?

then here:

$iRed = 0
$iBlue = 0

For $L=1 to 19
    $yLine=280+($L*20);  the Y coordination of the first line is 300; so 300-20 is 280
    MouseMove(28,$yLine);

    local $color1=PixelGetColor(28,$yLine)
    ;consolewrite($color1)

    if ($color1=14170419) then
        $iRed+=1
    endif
    if ($color1=24225) then
        $iBlue+=1
    endif
next

ConsoleWrite("Red: "&$iRed&@crlf)
ConsoleWrite("Blue: "&$iBlue&@crlf)

Sorry @junkew

i was too lazy to type it all so i borrowed most of yours

Edited by genius257
debug line
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...