sub findClickableStuff($img, $startx, $name, $clickonlyone) { my $listitemsfound = 0; for(my $iy = $listendy; $iy > $liststarty; $iy--) { my $found = 0; for(my $ix = 0; $ix < 90; $ix++) { my ($r, $g, $b) = $img->getpixel(x => $ix + $startx, y => $iy)->rgba(); if($r == 255 && $g == 255 && $b == 255) { # White text (or lines): List has at least one entry $listitemsfound = 1; } #next if($r > 180); #next if($g < 180); # Search for somewhat green text (means we can affort the item) if($r < 50 && $g > 220 && $b > 150) { $found = 1; last; } } if($found) { print $name, "item found!\n"; for(1..3) { click($startx + 45, $iy); } $iy -= 50; #$listitemsfound = 1; if($clickonlyone) { last; } } } return $listitemsfound; }