Jump to content

Free Rice Bot


keen
 Share

Recommended Posts

  • Replies 69
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

I get this error when trying to run this.

CODE
C:\Documents and Settings\David LaClair\Desktop\Test.au3(87,79) : WARNING: $WS_POPUP: possibly used before declaration.

$Form = GUICreate("Rice Bot", $Width, $Height, -1, -1, BitOR($WS_POPUP,

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

C:\Documents and Settings\David LaClair\Desktop\Test.au3(87,91) : WARNING: $WS_BORDER: possibly used before declaration.

$Form = GUICreate("Rice Bot", $Width, $Height, -1, -1, BitOR($WS_POPUP, $WS_BORDER)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

C:\Documents and Settings\David LaClair\Desktop\Test.au3(87,79) : ERROR: $WS_POPUP: undeclared global variable.

$Form = GUICreate("Rice Bot", $Width, $Height, -1, -1, BitOR($WS_POPUP,

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

C:\Documents and Settings\David LaClair\Desktop\Test.au3 - 1 error(s), 2 warning(s)

When using this code...

CODE
#include <IE.au3>

#include <INet.au3>

#include <String.au3>

#include <GUIConstants.au3>

Global $Correct = 0, $False = 0, $First = 1, $Label, $Timerdiff, $Formtitle, $Minute = 0

$oIE = _IECreate("http://freerice.com", 1, 0)

HotKeySet("{F10}", "hideshow")

While 1

$Timer = TimerInit()

$html = _IEBodyReadHTML($oIE)

Check()

$Word = StringRegExp($html, "(?i)<li><strong>(.*?)</strong>", 1)

$LearnWord = StringRegExp($html, '(?i)incorrect>(.*?)</div>', 1)

If IsArray($LearnWord) Then

$splitted = StringSplit($LearnWord[0], "=")

$learn = StringStripWS($splitted[1], 2)

$means = StringStripWS($splitted[2], 1)

ConsoleWrite(">Learned a new word!: " & $LearnWord[0] & @CRLF)

IniWrite("learning.ini", "Learned words", $learn, $means)

EndIf

$isLearned = IniRead("learning.ini", "Learned words", StringStripWS($Word[0], 8), "")

If $isLearned <> "" Then

ConsoleWrite("+>Found synonym. Clicking by text(learned word): " & $isLearned & @CRLF)

_IELinkClickByText($oIE, $isLearned)

Else

$SynonymsG = _GetSyn(StringStripWS($Word[0], 8))

If IsArray($SynonymsG) Then

$oLinks = _IELinkGetCollection($oIE)

$Found = False

For $oLink In $oLinks

For $a = 1 To $SynonymsG[0]

If StringInStr($oLink.href, "Javascript") Then

$test = _IEPropertyGet($oLink, "innertext")

If StringInStr($SynonymsG[$a], $test) Then

$WordToClick = $test

$Found = True

ExitLoop (2)

EndIf

EndIf

Next

Next

Else

$Found = False

EndIf

If $Found Then

ConsoleWrite("+>Found synonym. Clicking by text: " & $WordToClick & @CRLF)

_IELinkClickByText($oIE, $WordToClick)

Else

ConsoleWrite("-> Could not find synonym. Clicking random word." & @CRLF)

_IENavigate($oIE, "java script: submitForm('" & Random(1, 4, 1) & "')")

EndIf

EndIf

Sleep(1000)

$Timerdiff += TimerDiff($Timer)

$Second = Round($Timerdiff / 1000, 0)

If $Second >= 60 Then

$Second = 0

$Minute += 1

$Timerdiff = 0

EndIf

GUICtrlSetData($Formtitle, " Rice Bot - Minute: " & $Minute & " Second: " & $Second)

WEnd

Func hideshow()

If _IEPropertyGet($oIE, "visible") Then

_IEAction($oIE, "invisible")

Else

_IEAction($oIE, "visible")

EndIf

EndFunc ;==>hideshow

Func _GetSyn($sWord)

$sSource = _INetGetSource("http://www.synonymer.se/en/?query=" & $sWord & "&btnS=Find+synonyms")

$synonyms = StringRegExp($sSource, '(?i)class="synonym">(.*?)</TR>', 1)

If Not IsArray($synonyms) Then Return 0

$syns = StringSplit($synonyms[0], ",")

Return $syns

EndFunc ;==>_GetSyn

Func Check()

If $First = 1 Then

_IEAction($oIE, "invisible")

$Width = 270

$Height = 55

$Form = GUICreate("Rice Bot", $Width, $Height, -1, -1, BitOR($WS_POPUP, $WS_BORDER))

$Formtitle = GUICtrlCreateLabel(" Rice Bot", 0, 4, @DesktopWidth, 20, -1, $GUI_WS_EX_PARENTDRAG)

GUICtrlSetColor(-1, 0xFFFFFF)

GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)

$Formtitlebackground = GUICtrlCreateGraphic(0, 0, @DesktopWidth, 22)

GUICtrlSetBkColor(-1, 0x000000)

$Label = GUICtrlCreateLabel("", 8, 25, $Width, 50)

GUISetState()

WinSetTrans($Form, "", 200)

$First = 0

EndIf

$Amount = _StringBetween($html, '<P id=donatedAmount>', '</P>')

If IsArray($Amount) Then

$Amount2 = StringRegExp($Amount[0], "[[:digit:]]+", 1)

If Not @error Then

If StringInStr($html, '<div id=correct>CORRECT!</div>') Then

$Correct += 1

Else

$False += 1

EndIf

GUICtrlSetData($Label, "You have now donated " & $Amount2[0] & " grains of rice." & @CRLF & "Correct : " & $Correct & " False : " & $False & " Correct Percentage : " & Round((($Correct / ($Correct + $False)) * 100), 0) & "%")

EndIf

EndIf

EndFunc ;==>Check

And yes, I did fix the javascript error thing

My ProgramsMy WIP'sSteam Server Restarter
Link to comment
Share on other sites

I also get a $wS_pop error.. what include is that with?

I figured, if you goto the error spot, just remove that end part, the whole Bitor part, it still works :)

$Form = GUICreate("Rice Bot", $Width, $Height, -1, -1, BitOR($WS_POPUP, $WS_BORDER))

should be

$Form = GUICreate("Rice Bot", $Width, $Height, -1, -1)

Edited by Coolw
My ProgramsMy WIP'sSteam Server Restarter
Link to comment
Share on other sites

I HAVE read this whole post.. Yet i still come up with this error.. it runs for a few min then this error pops up.. But now its comming up even before it runs.. Any ideas?

C:\Documents and Settings\ScorpiA Regency\Desktop\Free Rice\Freerice2.au3 (25) : ==> Subscript used with non-Array variable.:
$isLearned = IniRead("learning.ini", "Learned words", StringStripWS($Word[0], 8), "")
$isLearned = IniRead("learning.ini", "Learned words", StringStripWS($Word^ ERROR
->18:50:09 AutoIT3.exe ended.rc:1
>Exit code: 1   Time: 2.735

#include <IE.au3>
#include <INet.au3>
#include <String.au3>
#include <GUIConstants.au3>
#Include <WindowsConstants.au3>

Global $Correct = 0, $False = 0, $First = 1, $Label, $Timerdiff, $Formtitle, $Minute = 0
$oIE = _IECreate("http://freerice.com", 1, 0)
HotKeySet("{F10}", "hideshow")

While 1
    $Timer = TimerInit()
    $html = _IEBodyReadHTML($oIE)
    Check()
    Sleep(1000)
    $Word = StringRegExp($html, "(?i)<li><strong>(.*?)</strong>", 1)
    $LearnWord = StringRegExp($html, '(?i)incorrect>(.*?)</div>', 1)
    If IsArray($LearnWord) Then
        $splitted = StringSplit($LearnWord[0], "=")
        $learn = StringStripWS($splitted[1], 2)
        $means = StringStripWS($splitted[2], 1)
        ConsoleWrite(">Learned a new word!: " & $LearnWord[0] & @CRLF)
        IniWrite("learning.ini", "Learned words", $learn, $means)
    EndIf
    $isLearned = IniRead("learning.ini", "Learned words", StringStripWS($Word[0], 8), "")
    If $isLearned <> "" Then
        ConsoleWrite("+>Found synonym. Clicking by text(learned word): " & $isLearned & @CRLF)
        _IELinkClickByText($oIE, $isLearned)
    Else
        $SynonymsG = _GetSyn(StringStripWS($Word[0], 8))
        If IsArray($SynonymsG) Then
            $oLinks = _IELinkGetCollection($oIE)
            $Found = False
            For $oLink In $oLinks
                For $a = 1 To $SynonymsG[0]
                    If StringInStr($oLink.href, "Javascript") Then
                        $test = _IEPropertyGet($oLink, "innertext")
                        If StringInStr($SynonymsG[$a], $test) Then
                            $WordToClick = $test
                            $Found = True
                            ExitLoop (2)
                        EndIf
                    EndIf
                Next
            Next
        Else
            $Found = False
        EndIf
        If $Found Then
            ConsoleWrite("+>Found synonym. Clicking by text: " & $WordToClick & @CRLF)
            _IELinkClickByText($oIE, $WordToClick)
        Else
            ConsoleWrite("-> Could not find synonym. Clicking random word." & @CRLF)
            _IENavigate($oIE, "java script: submitForm('" & Random(1, 4, 1) & "')")
        EndIf
    EndIf
    Sleep(1000)
    $Timerdiff += TimerDiff($Timer)
    $Second = Round($Timerdiff / 1000, 0)
    If $Second >= 60 Then
        $Second = 0
        $Minute += 1
        $Timerdiff = 0
    EndIf
    GUICtrlSetData($Formtitle, " Rice Bot - Minute: " & $Minute & " Second: " & $Second)
WEnd

Func hideshow()
    If _IEPropertyGet($oIE, "visible") Then
        _IEAction($oIE, "invisible")
    Else
        _IEAction($oIE, "visible")
    EndIf
EndFunc   ;==>hideshow

Func _GetSyn($sWord)
    $sSource = _INetGetSource("http://www.synonymer.se/en/?query=" & $sWord & "&btnS=Find+synonyms")
    $synonyms = StringRegExp($sSource, '(?i)class="synonym">(.*?)</TR>', 1)
    If Not IsArray($synonyms) Then Return 0
    $syns = StringSplit($synonyms[0], ",")
    Return $syns
EndFunc   ;==>_GetSyn

Func Check()
    If $First = 1 Then
        _IEAction($oIE, "invisible")
        $Width = 270
        $Height = 55
        $Form = GUICreate("Rice Bot", $Width, $Height, -1, -1, BitOR($WS_POPUP, $WS_BORDER))
        $Formtitle = GUICtrlCreateLabel(" Rice Bot", 0, 4, @DesktopWidth, 20, -1, $GUI_WS_EX_PARENTDRAG)
        GUICtrlSetColor(-1, 0xFFFFFF)
        GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
        $Formtitlebackground = GUICtrlCreateGraphic(0, 0, @DesktopWidth, 22)
        GUICtrlSetBkColor(-1, 0x000000)
        $Label = GUICtrlCreateLabel("", 8, 25, $Width, 50)
        GUISetState()
        WinSetTrans($Form, "", 200)
        $First = 0
    EndIf
    $Amount = _StringBetween($html, '<P id=donatedAmount>', '</P>')
    If IsArray($Amount) Then
        $Amount2 = StringRegExp($Amount[0], "[[:digit:]]+", 1)
        If Not @error Then
            If StringInStr($html, '<div id=correct>CORRECT!</div>') Then
                $Correct += 1
            Else
                $False += 1
            EndIf
            GUICtrlSetData($Label, "You have now donated " & $Amount2[0] & " grains of rice." & @CRLF & "Correct : " & $Correct & "  False : " & $False & "  Correct Percentage : " & Round((($Correct / ($Correct + $False)) * 100), 0) & "%")
        EndIf
    EndIf
EndFunc   ;==>Check

What am i doing wrong?

Link to comment
Share on other sites

i have some problem whit this bot...when random word start i got this in my autoit console

-> Could not find synonym. Clicking random word.
C:\Documents and Settings\The_Kymy\Desktop\bot.au3 (23) : ==> Subscript used with non-Array variable.: 
$isLearned = IniRead("learning.ini", "Learned words", StringStripWS($Word[0], 8), "") 
$isLearned = IniRead("learning.ini", "Learned words", StringStripWS($Word^ ERROR
>Exit code: 1   Time: 60.192

how i can fix it???

Link to comment
Share on other sites

can someone help me with this piece of code from the bot?

$Amount = _StringBetween($html, '<P id=donatedAmount>', '</P>')
    If IsArray($Amount) Then
        $Amount2 = StringRegExp($Amount[0], "[[:digit:]]+", 1)
        If Not @error Then
            If StringInStr($html, '<div id=correct>CORRECT!</div>') Then
                $Correct += 1
            Else
                $False += 1
            EndIf
            GUICtrlSetData($Label, "You have now donated " & $Amount2[0] & " grains of rice." & @CRLF & "Correct : " Correct & "  False : " & $False & "  Correct Percentage : " & Round((($Correct / ($Correct + $False)) * 100), 0) & "%")&
        EndIf
    EndIf

i want to include it in a script of my own, but i cant get it to work...

i did this

$Amount = _StringBetween($html, '<SPAN class=style3>', ''Move(s) Remaining</SPAN>')
     If IsArray($Amount) Then
          $Amount2 = StringRegExp($Amount[0], "[[:digit:]]+", 1)
    If Not @error Then
         If StringInStr($html, '<div id=correct>CORRECT!</div>') Then
              $Correct += 1
         Else
              $False += 1
         EndIf
         GUICtrlSetData($Label, "You have " & $Amount2[0] & " moves left.")
    EndIf
     EndIf

any help is welcome :)

Damian666

Edited by damian666
and proud of it!!!
Link to comment
Share on other sites

oh, btw, the thing that doesnt work, is i dont get to see anything, no numbers nothing.

so it wont read the string between those two strings for some reason.

i did check if teh html was read, and it was...

:S

Damian666

and proud of it!!!
Link to comment
Share on other sites

  • 2 weeks later...

Works nicely! By the way, added a delay that works very nice! (Hasn't froze up so far: half an hour)

ConsoleWrite(">Learned a new word!: " & $LearnWord[0] & @CRLF)
        IniWrite("learning.ini", "Learned words", $learn, $means)
    EndIf
    $isLearned = IniRead("learning.ini", "Learned words", StringStripWS($Word[0], 8), "")
    sleep (500)
    If $isLearned <> "" Then
        ConsoleWrite("+>Found synonym. Clicking by text(learned word): " & $isLearned & @CRLF

Add sleep (500) between $isLearned and If $isLearned. It pauses the script long enough to let the server catch up.

Edited by HypercamJ
Prove, and I will believe...
Link to comment
Share on other sites

Ran this bot overnight, had no issues, and donated 45k.

No, you stole 45k.

The website pays for the rice by displaying advertisements to the client. If you are using a bot, then nobody is seeing the advertisements.

Link to comment
Share on other sites

No, you stole 45k.

The website pays for the rice by displaying advertisements to the client. If you are using a bot, then nobody is seeing the advertisements.

Technically, the bot has the window hidden but im looking at them without seeing them.
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...