func SellItems()
dim $ItemsArray[6][2]
$ItemsArray[0][0] = 0
$ItemsArray[1][0] = 0
$ItemsArray[2][0] = 0
$ItemsArray[3][0] = 0
$ItemsArray[4][0] = 0
$ItemsArray[5][0] = 0
local $InvLeft = 505, $InvTop = 228, $invRight = 745, $InvBottom = 392 ;the square to scan for items
local $numPixelsFound = 0, $ConsecutiveLines = 0, $ItemsArrayIndex = 0
for $y = $InvTop to $InvBottom ;scan top to bottom...
for $x = $InvLeft to $invRight ;... left to right
if PixelGetColor( $x, $y ) == $ItemColor_White then $numPixelsFound += 1 ;get the total pixels per lines
Next
if $numPixelsFound < 2 then
;this line is empty
;_log( $y & ' is empty' )
if $ConsecutiveLines > 3 then
;this means we found an item and are at the end of it
_log( 'Item end found, Start = ' & $y - $ConsecutiveLines & ' End = ' & ($y - 1) & ' Size = ' & $ConsecutiveLines )
_log( 'Item code = ' & SpecificChecksum( $InvLeft, $y - $ConsecutiveLines, $invRight, $y - 1, $ItemColor_White ) )
$ItemsArray[$ItemsArrayIndex][0] = $y - $ConsecutiveLines
$ItemsArray[$ItemsArrayIndex][1] = $y - 1
$ItemsArrayIndex +=1 ;increase the index
EndIf
$ConsecutiveLines = 0
Else
;this line contains white pixels
_log( $y & ' contains white pixels. Total pixels found: ' & $numPixelsFound )
$ConsecutiveLines += 1
EndIf
$numPixelsFound = 0
Next
local $LastItem = 5
for $i = 0 to 5
if $ItemsArray[$i][0] == 0 then
$LastItem = $i
ExitLoop
EndIf
Next
dim $SellItems[6]
$SellItems[0] = false
$SellItems[1] = false
$SellItems[2] = false
$SellItems[3] = false
$SellItems[4] = false
$SellItems[5] = false
local $continueloop
for $i = 0 to $LastItem ;-1
$continueloop = true
Switch( $i )
case 1
for $x = $InvLeft to $invRight ;... left to right
if PixelGetColor( $x, $InvTop -1 ) == $ItemColor_White Then
$SellItems[0] = False
$continueloop = false
EndIf
Next
case 5
for $x = $InvLeft to $invRight ;... left to right
if PixelGetColor( $x, $InvBottom + 1 ) == $ItemColor_White then
$SellItems[5] = false
$continueloop = false
EndIf
Next
EndSwitch
if not $ContinueLoop then ContinueLoop
if $i > 5 then ExitLoop
_log( 'Selling item #' & $i & ' to true' )
$SellItems[$i] = true
$ItemCode = SpecificChecksum( $InvLeft,$ItemsArray[$i][0],$invRight,$ItemsArray[$i][1], $ItemColor_White )
_log($ItemCode)
for $a = 0 to UBound( $KeepItems ) - 1
if $ItemCode == $KeepItems[$a] then
_log( 'Item is in keep items list. current item: ' & $ItemCode & ' List item: ' & $KeepItems[$a] )
$SellItems[$i] = false
ExitLoop
EndIf
Next
Next
for $i = 0 to 5
if $SellItems[$i] == true then
if $ItemsArray[$i][0] < $InvTop then ContinueLoop ;this is a GAY bug, sometime i click out of inv (I think y = 0) must investigate, this is a temp fix
_log( 'Selling item #' & $i )
;todo sell item
MouseClick( 'left', $InvLeft + 50, $ItemsArray[$i][0] + 4 )
Sleep( Random( 1000, 2000 ) )
MouseClick( 'left',799,597 )
Sleep( Random( 1000, 2000 ) )
return true
Else
_log( 'Dosent selling item #' & $i )
EndIf
Next
return False
;if return false it means no item is sold, so scrool or if at end exit, return true will ONLY sell 1 item.
EndFunc
func SpecificChecksum($left, $top, $right, $bottom, $color)
local $LastFound, $ConsecutiveFails = 0, $TotalColors = 0
local $sum2[255];array of bytes
local $sum = 0, $index = 1, $byteIndex = 0,$started = false
for $x5 = $right to $left step -3
for $y5 = $Bottom to $Top - 14 step -3
if PixelGetColor( $x5, $y5 ) == $color then
$sum += $index
$started = true
EndIf
if not $started then ContinueLoop
$index = $index *2
if $index > 4294967295 then
;add the byte into the array
$sum2[$byteIndex] = Hex( $sum )
$sum = 0
$byteIndex += 1
$index = 1
EndIf
Next
Next
;built the string off the bytes
$bytestring = ''
for $i = $byteIndex to 0 step -1
$bytestring &= Hex( $sum2[$i] )
Next
$bytestring = StringReplace( $bytestring, '0','')
return $bytestring
EndFunc