Jump to content

Bad loop


Recommended Posts

Good morning everybody. I have a script I am trying to create, and I am having problems with restarting a gui. What I have so far is just a rough draft, things to be added later, but I need help. This is a 5 letter word guessing game and when you play, it picks a random 5 letter word from a file. It gives you the first letter, then you have to guess the rest. As you get any correct letters, it shows in the gui. Once you guessed the right word, it is supposed to start a new game, giving the new first letter. when I run this, it works up to the point you guess the correct word. Once you click OK on the message box that comes up, it should start over, but it tries to create the gui again, and just creates more "empty" gui's, making it hard to even stop the script. Any ideas on how I can get this to work correctly? I am attaching my "script". If it doesn't appear correctly, please let me know how to post a different way. As you will see, I probably did some things the hard\long way, but this is just a rough draft. Thank you for any help you can give.

Byteme

MyGame.au3

Link to comment
Share on other sites

Well, since I don't have too much time to spare because of all these stupid tests at school, this is what I hvae made of it so far. I think you can do the rest yourself (or if not, let us know lol)

#include <file.au3>
#include <math.au3>
#include <GuiConstants.au3>

$tick = 1

HotKeySet("{enter}", "click")
If Not FileExists("c:\temp\money.ini") Then
    IniWrite("C:\Temp\money.ini", "name", "money", "500")
EndIf
$l1 = ""
$l2 = ""
$l3 = ""
$l4 = ""
$l5 = ""

_getrandom()


$mainwindow = GUICreate("My Game", @DesktopWidth, @DesktopHeight, 1, 1, $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)
$l1 = GUICtrlCreateInput("", 170, 30, 89, 93)
GUICtrlSetFont($l1, 50)
$l2 = GUICtrlCreateInput("", 270, 30, 89, 93)
GUICtrlSetFont($l2, 50)
$l3 = GUICtrlCreateInput("", 370, 30, 89, 93)
GUICtrlSetFont($l3, 50)
$l4 = GUICtrlCreateInput("", 470, 30, 89, 93)
GUICtrlSetFont($l4, 50)
$l5 = GUICtrlCreateInput("", 570, 30, 89, 93)
GUICtrlSetFont($l5, 50)
$Button_6 = GUICtrlCreateButton("Submit", 200, 350, 120, 40)
$Button_7 = GUICtrlCreateButton("Quit", 420, 350, 120, 40)
$monlabel = GUICtrlCreateLabel("", 620, 300, 120, 25)
$money = IniRead("c:\temp\money.ini", "name", "money", "500")
GUICtrlSetData($monlabel, "money: " & $money)
$guess = GUICtrlCreateInput("", 260, 270, 230, 50)
GUICtrlSetFont($guess, 20)
GUISetState()

While 1
    $msg = GUIGetMsg()
    $w1 = StringMid($lr, 1, 1)
    Select
        Case $msg = $Button_6
            $w1 = StringMid($lr, 1, 1)
            $w2 = StringMid($lr, 2, 1)
            $w3 = StringMid($lr, 3, 1)
            $w4 = StringMid($lr, 4, 1)
            $w5 = StringMid($lr, 5, 1)
            $guess2 = GUICtrlRead($guess)
            $g1 = StringMid($guess2, 1, 1)
            $g2 = StringMid($guess2, 2, 1)
            $g3 = StringMid($guess2, 3, 1)
            $g4 = StringMid($guess2, 4, 1)
            $g5 = StringMid($guess2, 5, 1)
            GUICtrlSetData($guess, "")
            If $w1 = $g1 Then
                GUICtrlSetData($l1, $w1)
            EndIf
            If $w2 = $g2 Then
                GUICtrlSetData($l2, $w2)
            EndIf
            If $w3 = $g3 Then
                GUICtrlSetData($l3, $w3)
            EndIf
            If $w4 = $g4 Then
                GUICtrlSetData($l4, $w4)
            EndIf
            If $w5 = $g5 Then
                GUICtrlSetData($l5, $w5)
            EndIf
        Case $msg = $Button_7
            Exit
        Case $msg = $GUI_EVENT_CLOSE
            Exit
    EndSelect
    $f1 = GUICtrlRead($l1)
    $f2 = GUICtrlRead($l2)
    $f3 = GUICtrlRead($l3)
    $f4 = GUICtrlRead($l4)
    $f5 = GUICtrlRead($l5)
    If $f1 <> "" And $f2 <> "" And $f3 <> "" And $f4 <> "" And $f5 <> "" Then
        MsgBox(0, "you got it!", "you got it!")
        ;$l1 = ""
        ;$l2 = ""
        ;$l3 = ""
        ;$l4 = ""
        ;$l5 = ""
        $tick = 2
        ControlSetText($mainwindow, "", $l1, "")
        ControlSetText($mainwindow, "", $l2, "")
        ControlSetText($mainwindow, "", $l3, "")
        ControlSetText($mainwindow, "", $l4, "")
        ControlSetText($mainwindow, "", $l5, "")
        _getrandom()
    EndIf
WEnd

Func click()
    ControlClick("My Game", "", $Button_6)
EndFunc   ;==>click

Func _getrandom()
    $t = "c:\5lw.txt"
    $lines = _FileCountLines($t)
    $rnd = Random(1, $lines, 1)
    Global $lr = FileReadLine($t, $rnd)
    GUICtrlSetData($l1, $lr)
    ;msgbox(0, "read", "I picked " & $lr)
EndFunc

Note that I didn't change anything world schockingly, mainly (as you said) the loops, and there could very well be some things you want to do differently!

Alzo

Edited by marfdaman

Don't take my pic to serious...~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~You Looked, but you did not see!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Link to comment
Share on other sites

I'm sorry....Just one more question here. Right now when the gui opens, you click into the one input box where you can type your word. if you hit enter, the click function clicks on submit. after that, is there a way to make the inputbox for the user to type another word in automatically be active so they don't have to click into it first??? thank you all again....

Byteme

Link to comment
Share on other sites

You mean like this:

Func click()
    ControlClick("My Game", "", $Button_6)
    GUICtrlSetState($l1, $GUI_FOCUS)
EndFunc   ;==>click

Edit: no need to apologize, only 2 months ago I wouldn't have had a clue how to do that :D

Edited by marfdaman

Don't take my pic to serious...~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~You Looked, but you did not see!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Link to comment
Share on other sites

hahaha! sooo simple, yet I missed it! thank you once again and have a wonderful day!

Byteme

haha the same to you!

Don't take my pic to serious...~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~You Looked, but you did not see!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Link to comment
Share on other sites

  • Moderators

hahaha! sooo simple, yet I missed it! thank you once again and have a wonderful day!

Byteme

See what you think of this:

#include <IE.au3>
#include <file.au3>
#include <GuiConstants.au3>

If Not FileExists(@TempDir & "\money.ini") Then
    IniWrite(@TempDir & "\money.ini", "name", "money", "500")
EndIf
If Not FileExists(@TempDir & "\five_letter_words.txt") Then
    _IEErrorHandlerRegister ()
    $oIE = _IECreate ("http://www.esclub.gr/games/wordox/5.html", 0, 0)
    $oTag = _IETagNameGetCollection ($oIE, "p", 8)
    $sWords = $oTag.innerText
    $sWords = StringReplace($sWords, "5 letter words", "")
    $sWords = StringReplace($sWords, @CRLF, "")
    $sWords = StringReplace($sWords, " ", @CRLF)
    FileWrite(@TempDir & "\five_letter_words.txt", $sWords)
    _IEQuit ($oIE)
EndIf

Global $lr

$mainwindow = GUICreate("My Game", @DesktopWidth, @DesktopHeight, 1, 1, $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)
$l1 = GUICtrlCreateInput("", 170, 30, 89, 93, $ES_CENTER + $ES_READONLY)
GUICtrlSetFont($l1, 50)
$l2 = GUICtrlCreateInput("", 270, 30, 89, 93, $ES_CENTER + $ES_READONLY)
GUICtrlSetFont($l2, 50)
$l3 = GUICtrlCreateInput("", 370, 30, 89, 93, $ES_CENTER + $ES_READONLY)
GUICtrlSetFont($l3, 50)
$l4 = GUICtrlCreateInput("", 470, 30, 89, 93, $ES_CENTER + $ES_READONLY)
GUICtrlSetFont($l4, 50)
$l5 = GUICtrlCreateInput("", 570, 30, 89, 93, $ES_CENTER + $ES_READONLY)
GUICtrlSetFont($l5, 50)
$Button_6 = GUICtrlCreateButton("Submit", 200, 350, 120, 40, $BS_DEFPUSHBUTTON)
$Button_7 = GUICtrlCreateButton("Quit", 420, 350, 120, 40)
$monlabel = GUICtrlCreateLabel("", 620, 300, 120, 25)
$money = IniRead("c:\temp\money.ini", "name", "money", "500")
GUICtrlSetData($monlabel, "money: " & $money)
$guess = GUICtrlCreateInput("", 260, 270, 230, 50)
GUICtrlSetFont($guess, 20)
GUISetState()

_getrandom()

While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $Button_6
            $w1 = StringMid($lr, 1, 1)
            $w2 = StringMid($lr, 2, 1)
            $w3 = StringMid($lr, 3, 1)
            $w4 = StringMid($lr, 4, 1)
            $w5 = StringMid($lr, 5, 1)
            $guess2 = GUICtrlRead($guess)
            $g1 = StringMid($guess2, 1, 1)
            $g2 = StringMid($guess2, 2, 1)
            $g3 = StringMid($guess2, 3, 1)
            $g4 = StringMid($guess2, 4, 1)
            $g5 = StringMid($guess2, 5, 1)
            GUICtrlSetData($guess, "")
            If $w1 = $g1 Then GUICtrlSetData($l1, $w1)
            If $w2 = $g2 Then GUICtrlSetData($l2, $w2)
            If $w3 = $g3 Then GUICtrlSetData($l3, $w3)
            If $w4 = $g4 Then GUICtrlSetData($l4, $w4)
            If $w5 = $g5 Then GUICtrlSetData($l5, $w5)
            $f1 = GUICtrlRead($l1)
            $f2 = GUICtrlRead($l2)
            $f3 = GUICtrlRead($l3)
            $f4 = GUICtrlRead($l4)
            $f5 = GUICtrlRead($l5)
            If $f1 = $w1 And $f2 = $w2 And $f3 = $w3 And $f4 = $w4 And $f5 = $w5 Then
                MsgBox(0, "you got it!", "you got it!")
                GUICtrlSetData($l1, "")
                GUICtrlSetData($l2, "")
                GUICtrlSetData($l3, "")
                GUICtrlSetData($l4, "")
                GUICtrlSetData($l5, "")
                _getrandom()
            EndIf
            GUICtrlSetState($guess, $GUI_FOCUS)
        Case $Button_7, $GUI_EVENT_CLOSE
            Exit
        Case Else
            Sleep(10)
    EndSwitch
WEnd

Func _getrandom()
    $t = @TempDir & "\five_letter_words.txt"
    $lines = _FileCountLines($t)
    $rnd = Random(1, $lines, 1)
    $lr = FileReadLine($t, $rnd)
    GUICtrlSetData($l1, StringMid($lr, 1, 1))
    ;MsgBox(0, "read", "I picked " & $lr)
EndFunc   ;==>_getrandom
Link to comment
Share on other sites

  • Moderators

Cute... Big d

8)

Thanks, I added the money functionality and modified the gui a little.

#include <IE.au3>
#include <file.au3>
#include <GuiConstants.au3>

If Not FileExists(@TempDir & "\money.ini") Then
    IniWrite(@TempDir & "\money.ini", "name", "money", "500")
EndIf
If Not FileExists(@TempDir & "\five_letter_words.txt") Then
    SplashTextOn("Please Wait...", "Please wait while the word list is being downloaded.", 250, 50)
    _IEErrorHandlerRegister ()
    $oIE = _IECreate ("http://www.esclub.gr/games/wordox/5.html", 0, 0)
    $oTag = _IETagNameGetCollection ($oIE, "p", 8)
    $sWords = $oTag.innerText
    $sWords = StringReplace($sWords, "5 letter words", "")
    $sWords = StringReplace($sWords, @CRLF, "")
    $sWords = StringReplace($sWords, " ", @CRLF)
    FileWrite(@TempDir & "\five_letter_words.txt", $sWords)
    _IEQuit ($oIE)
    SplashOff()
EndIf

Global $lr, $money

$mainwindow = GUICreate("My Game", 600, 400, @DesktopWidth/2-300, @DesktopHeight/2-200);, $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)
$l1 = GUICtrlCreateInput("", 30, 30, 100, 100, $ES_CENTER + $ES_READONLY)
GUICtrlSetResizing(-1, $GUI_DOCKSIZE)
GUICtrlSetFont(-1, 55)
$l2 = GUICtrlCreateInput("", 140, 30, 100, 100, $ES_CENTER + $ES_READONLY)
GUICtrlSetResizing(-1, $GUI_DOCKSIZE)
GUICtrlSetFont(-1, 55)
$l3 = GUICtrlCreateInput("", 250, 30, 100, 100, $ES_CENTER + $ES_READONLY)
GUICtrlSetResizing(-1, $GUI_DOCKSIZE)
GUICtrlSetFont(-1, 55)
$l4 = GUICtrlCreateInput("", 360, 30, 100, 100, $ES_CENTER + $ES_READONLY)
GUICtrlSetResizing(-1, $GUI_DOCKSIZE)
GUICtrlSetFont(-1, 55)
$l5 = GUICtrlCreateInput("", 470, 30, 100, 100, $ES_CENTER + $ES_READONLY)
GUICtrlSetResizing(-1, $GUI_DOCKSIZE)
GUICtrlSetFont(-1, 55)
$Button_6 = GUICtrlCreateButton("Submit", 110, 300, 120, 40, $BS_DEFPUSHBUTTON)
$Button_7 = GUICtrlCreateButton("Quit", 370, 300, 120, 40)
$monlabel = GUICtrlCreateLabel("", 30, 10, 200, 20)
$guess = GUICtrlCreateInput("", 180, 200, 240, 50, $ES_CENTER)
GUICtrlSetFont(-1, 30)
GUICtrlSetState(-1, $GUI_FOCUS)
GUISetState()

_getrandom()
_getmoney()

While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $Button_6
            $w1 = StringMid($lr, 1, 1)
            $w2 = StringMid($lr, 2, 1)
            $w3 = StringMid($lr, 3, 1)
            $w4 = StringMid($lr, 4, 1)
            $w5 = StringMid($lr, 5, 1)
            $guess2 = GUICtrlRead($guess)
            $g1 = StringMid($guess2, 1, 1)
            $g2 = StringMid($guess2, 2, 1)
            $g3 = StringMid($guess2, 3, 1)
            $g4 = StringMid($guess2, 4, 1)
            $g5 = StringMid($guess2, 5, 1)
            GUICtrlSetData($guess, "")
            If $w1 = $g1 Then GUICtrlSetData($l1, $w1)
            If $w2 = $g2 Then GUICtrlSetData($l2, $w2)
            If $w3 = $g3 Then GUICtrlSetData($l3, $w3)
            If $w4 = $g4 Then GUICtrlSetData($l4, $w4)
            If $w5 = $g5 Then GUICtrlSetData($l5, $w5)
            $f1 = GUICtrlRead($l1)
            $f2 = GUICtrlRead($l2)
            $f3 = GUICtrlRead($l3)
            $f4 = GUICtrlRead($l4)
            $f5 = GUICtrlRead($l5)
            If $f1 = $w1 And $f2 = $w2 And $f3 = $w3 And $f4 = $w4 And $f5 = $w5 Then
                MsgBox(0, "You got it!", "You got it!")
                GUICtrlSetData($l1, "")
                GUICtrlSetData($l2, "")
                GUICtrlSetData($l3, "")
                GUICtrlSetData($l4, "")
                GUICtrlSetData($l5, "")
                _getrandom()
                _getmoney(1)
            Else
                _getmoney(0)
            EndIf
            GUICtrlSetState($guess, $GUI_FOCUS)
        Case $Button_7, $GUI_EVENT_CLOSE
            Exit
        Case Else
            Sleep(10)
    EndSwitch
WEnd

Func _getrandom()
    $t = @TempDir & "\five_letter_words.txt"
    $lines = _FileCountLines($t)
    $rnd = Random(1, $lines, 1)
    $lr = FileReadLine($t, $rnd)
    GUICtrlSetData($l1, StringMid($lr, 1, 1))
    ;MsgBox(0, "read", "I picked " & $lr)
EndFunc   ;==>_getrandom

Func _getmoney($i = -1)
    Switch $i
        Case 0
            $money = IniRead(@TempDir & "\money.ini", "name", "money", "0")-10
            IniWrite(@TempDir & "\money.ini", "name", "money", $money)
        Case 1
            $money = IniRead(@TempDir & "\money.ini", "name", "money", "0")+10
            IniWrite(@TempDir & "\money.ini", "name", "money", $money)
        Case Else
            $money = IniRead(@TempDir & "\money.ini", "name", "money", "500")
    EndSwitch
    GUICtrlSetData($monlabel, "Money: " & $money)
EndFunc

Edit: fixed the SplashText

Edited by big_daddy
Link to comment
Share on other sites

  • Moderators

I feel like I'm spamming here, but I totally rewrote this lastnight. Let me know if you find any bugs or have any suggestions.

Added: Reset Money Button

Added: Hint Button

Added: Word Definitions

Added: Ability to use your own word list if internet is unavailable.

Enhanced: Scoring function

You will need the IE.au3 library, and the latest beta

#include <IE.au3>
#include <File.au3>
#include <GuiConstants.au3>

Global $lr
Global $Money
Global $oIE

If Not FileExists(@TempDir & "\money.ini") Then
    IniWrite(@TempDir & "\money.ini", "name", "money", "500")
EndIf
If Not FileExists(@TempDir & "\five_letter_words.txt") Then
    SplashTextOn("Please Wait...", "Please wait while the word list is being downloaded.", 250, 50)
    _IEErrorHandlerRegister ()
    $oIE = _IECreate ("http://www.esclub.gr/games/wordox/5.html", 0, 0)
    $oTag = _IETagNameGetCollection ($oIE, "p", 8)
    If IsObj($oTag) Then
        $sWords = $oTag.innerText
        $sWords = StringReplace($sWords, "5 letter words", "")
        $sWords = StringReplace($sWords, @CRLF, "")
        $sWords = StringReplace($sWords, " ", @CRLF)
        FileWrite(@TempDir & "\five_letter_words.txt", $sWords)
        _IEQuit ($oIE)
        SplashOff()
    Else
        SplashOff()
        If MsgBox(52, "Error", "There was a problem downloading the file." & @CRLF & @CRLF & _
                "Would you like to specify your own word list?") = 6 Then
            $sPath = FileOpenDialog("Word List", @ScriptDir, "Text File (*.txt)", 1)
            If $sPath <> "" Then
                $sWords = FileRead($sPath)
                FileWrite(@TempDir & "\five_letter_words.txt", $sWords)
            EndIf
        Else
            Exit
        EndIf
    EndIf
EndIf

$GUI = GUICreate("My Game", 600, 400, @DesktopWidth / 2 - 300, @DesktopHeight / 2 - 200)
$l1 = GUICtrlCreateInput("", 30, 30, 100, 100, $ES_CENTER + $ES_READONLY)
GUICtrlSetResizing(-1, $GUI_DOCKSIZE)
GUICtrlSetFont(-1, 55)
$l2 = GUICtrlCreateInput("", 140, 30, 100, 100, $ES_CENTER + $ES_READONLY)
GUICtrlSetResizing(-1, $GUI_DOCKSIZE)
GUICtrlSetFont(-1, 55)
$l3 = GUICtrlCreateInput("", 250, 30, 100, 100, $ES_CENTER + $ES_READONLY)
GUICtrlSetResizing(-1, $GUI_DOCKSIZE)
GUICtrlSetFont(-1, 55)
$l4 = GUICtrlCreateInput("", 360, 30, 100, 100, $ES_CENTER + $ES_READONLY)
GUICtrlSetResizing(-1, $GUI_DOCKSIZE)
GUICtrlSetFont(-1, 55)
$l5 = GUICtrlCreateInput("", 470, 30, 100, 100, $ES_CENTER + $ES_READONLY)
GUICtrlSetResizing(-1, $GUI_DOCKSIZE)
GUICtrlSetFont(-1, 55)
$Button1 = GUICtrlCreateButton("Submit", 110, 300, 120, 40, $BS_DEFPUSHBUTTON)
$Button2 = GUICtrlCreateButton("Hint", 240, 300, 120, 40)
$Button3 = GUICtrlCreateButton("Quit", 370, 300, 120, 40)
$Button4 = GUICtrlCreateButton("Reset", 30, 5, 40, 20)
$Label1 = GUICtrlCreateLabel("", 80, 10, 200, 20)
$Checkbox1 = GUICtrlCreateCheckbox("Toggle Definitions", 5, 335, 100, 20)
GUICtrlSetState(-1, $GUI_CHECKED)
$Edit1 = GUICtrlCreateEdit("Once you guess the word, it's definition will be displayed here.", _
        0, 355, 600, 45, $ES_READONLY + $ES_MULTILINE)
$Input1 = GUICtrlCreateInput("", 180, 200, 240, 50, $ES_CENTER)
GUICtrlSetFont(-1, 30)
GUICtrlSetState(-1, $GUI_FOCUS)
GUISetState()

_GetRandomWord()
_GetMoney()

While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $Button1
            $Match = False
            $NumMatch = 0
            $sString = GUICtrlRead($Input1)
            GUICtrlSetData($Input1, "")
            For $i = 1 To 5
                Assign("w" & $i, StringMid($lr, $i, 1))
            Next
            For $i = 1 To 5
                Assign("g" & $i, StringMid($sString, $i, 1))
            Next
            For $i = 1 To 5
                If Eval("w" & $i) = Eval("g" & $i) And Eval("g" & $i) <> GUICtrlRead(Eval("l" & $i)) Then
                    GUICtrlSetData(Eval("l" & $i), Eval("w" & $i))
                    $Match = True
                EndIf
            Next
            For $i = 1 To 5
                Assign("f" & $i, GUICtrlRead(Eval("l" & $i)))
            Next
            For $i = 1 To 5
                If Eval("f" & $i) = Eval("w" & $i) Then
                    $NumMatch += 1
                EndIf
            Next
            If $NumMatch = 5 Then
                MsgBox(0, "", "Correct!", 2)
                For $i = 1 To 5
                    GUICtrlSetData(Eval("l" & $i), "")
                Next
                _GetDef($lr)
                _GetRandomWord()
                _GetMoney(1)
            Else
                If Not $Match Then
                    _GetMoney(0)
                EndIf
            EndIf
            GUICtrlSetState($Input1, $GUI_FOCUS)
        Case $Button2
            _GetHint(Random(1, 5, 1))
        Case $Button4
            IniWrite(@TempDir & "\money.ini", "name", "money", "500")
            _GetMoney()
        Case $Checkbox1
            Switch GUICtrlRead($Checkbox1)
                Case $GUI_UNCHECKED
                    GUICtrlSetData($Edit1, "Definitions will not be looked up.")
                Case $GUI_CHECKED
                    GUICtrlSetData($Edit1, "Once you guess the correct word, it's definition will be displayed here.")
            EndSwitch
        Case $Button3, $GUI_EVENT_CLOSE
            Exit
        Case Else
            Sleep(10)
    EndSwitch
WEnd

Func _GetRandomWord()
    $t = @TempDir & "\five_letter_words.txt"
    $lines = _FileCountLines($t)
    $rnd = Random(1, $lines, 1)
    $lr = FileReadLine($t, $rnd)
    $rndnum = Random(1, 5, 1)
    GUICtrlSetData(Eval("l" & $rndnum), StringMid($lr, $rndnum, 1))
EndFunc   ;==>_GetRandomWord

Func _GetMoney($i = -1)
    Switch $i
        Case 0
            $Money = IniRead(@TempDir & "\money.ini", "name", "money", "0") - 10
            IniWrite(@TempDir & "\money.ini", "name", "money", $Money)
        Case 1
            $Money = IniRead(@TempDir & "\money.ini", "name", "money", "0") + 100
            IniWrite(@TempDir & "\money.ini", "name", "money", $Money)
        Case Else
            $Money = IniRead(@TempDir & "\money.ini", "name", "money", "500")
    EndSwitch
    GUICtrlSetData($Label1, "Money: " & $Money)
EndFunc   ;==>_GetMoney

Func _GetHint($i)
    Switch $i
        Case 1
            GUICtrlSetData($l1, StringMid($lr, $i, 1))
        Case 2
            GUICtrlSetData($l2, StringMid($lr, $i, 1))
        Case 3
            GUICtrlSetData($l3, StringMid($lr, $i, 1))
        Case 4
            GUICtrlSetData($l4, StringMid($lr, $i, 1))
        Case 5
            GUICtrlSetData($l5, StringMid($lr, $i, 1))
    EndSwitch
    $Money = IniRead(@TempDir & "\money.ini", "name", "money", "0") - 20
    IniWrite(@TempDir & "\money.ini", "name", "money", $Money)
    GUICtrlSetData($Label1, "Money: " & $Money)
    GUICtrlSetState($Input1, $GUI_FOCUS)
EndFunc   ;==>_GetHint

Func _GetDef($s_word)
    Local $sDef = ""
    If GUICtrlRead($Checkbox1) = $GUI_UNCHECKED Then
        Return 0
    EndIf
    If $s_word <> "" Then
        GUICtrlSetData($Edit1, "Please wait while a definition is found.")
        If Not IsObj($oIE) Then
            $oIE = _IECreate ("about:blank", 0, 0)
        EndIf
        _IENavigate ($oIE, "http://en.wiktionary.org/w/index.php?title=" & $s_word & "&printable=yes")
        $BodyText = _IEBodyReadText ($oIE)
        If Not StringInStr($BodyText, "Wiktionary does not have an entry for this exact word yet.") Then
            $sDef = $s_word & ": "
            $oTags = _IETagNameGetCollection ($oIE, "ol")
            If IsObj($oTags) Then
                For $oTag In $oTags
                    $sText = $oTag.innerText
                    $sDef &= $sText
                Next
            Else
                $sDef = "Sorry, could not find a definition."
            EndIf
        Else
            $sDef = "Sorry, could not find a definition."
        EndIf
    EndIf
    GUICtrlSetData($Edit1, $sDef)
    GUICtrlSetState($Input1, $GUI_FOCUS)
EndFunc   ;==>_GetDef

Func OnAutoItExit()
    If IsObj($oIE) Then _IEQuit($oIE)
EndFunc   ;==>OnAutoItExit

Edit: added requirements

Edit: added the OnAutoItExit Function

Edit: added $oIE as Global Variable

Edited by big_daddy
Link to comment
Share on other sites

Hi Big d. I was the one who started this post, and i was looking at your code. I want to check it out because it looks very interesting. the problem is, I don't seem to have the ie.au3 file anywhere. I just installed v3.1.1.126 (beta) and I still don't have it. am I missing something here? any help would be appreciated....thanks!

Byteme

Link to comment
Share on other sites

  • Moderators

Hi Big d. I was the one who started this post, and i was looking at your code. I want to check it out because it looks very interesting. the problem is, I don't seem to have the ie.au3 file anywhere. I just installed v3.1.1.126 (beta) and I still don't have it. am I missing something here? any help would be appreciated....thanks!

Byteme

Sorry, I always seem to forget to put links to the requirements.

IE.au3

Edited by big_daddy
Link to comment
Share on other sites

Wow, that's very nice! I haven't done much scripting, and I have seen the ie.au3 out there, but never looked at it. this will come in very handy! I like how you go to the net to grab the words and definitions. very nice.

Byteme

Link to comment
Share on other sites

  • Moderators

Wow, that's very nice! I haven't done much scripting, and I have seen the ie.au3 out there, but never looked at it. this will come in very handy! I like how you go to the net to grab the words and definitions. very nice.

Byteme

Thank you, however you may want to copy the script again. I forgot to add the OnAutoItExit Function that closes the IE Window, otherwise it leaves it open after the script is closed.
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...