Jump to content
Sign in to follow this  
d0n

Missing variable?

Recommended Posts

d0n

When i run this code it says i haven't set the $mob variable, but i did it when i click my button, not sure whats wrong here

#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
Opt("Sendkeydelay", 1000)

$FV_1 = "C:\Documents and Settings\Admin\Desktop\bot\FV_1.bmp"
$FV_2 = "C:\Documents and Settings\Admin\Desktop\bot\FV_2.bmp"
$Title = "Night"
$1 = 1
$2 = 3

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 127, 263, 395, 258)
$Label1 = GUICtrlCreateLabel("", 8, 40, 127, 17)
$Combo1 = GUICtrlCreateCombo("", 0, 8, 121, 25)
GUICtrlSetData(-1, "FV_1|FV_2", "") 
$Button1 = GUICtrlCreateButton("Start", 0, 224, 57, 33, $WS_GROUP)
$Button2 = GUICtrlCreateButton("Stop", 64, 224, 57, 33, $WS_GROUP)
$Pic1 = GUICtrlCreatePic("", 8, 112, 108, 100, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

Gui()

Func Gui()
While 1
    $Msg = GUIGetMsg()
    Select
    Case $Msg = $Combo1
        $Selection = GUICtrlRead($Combo1)
        IF $Selection = "FV_1" Then
            GUICtrlSetImage($Pic1,$FV_1)
            GUICtrlSetData($Label1,"Bear")
        ElseIf $Selection = "FV_2" Then
            GUICtrlSetImage($Pic1,$FV_2)
            GUICtrlSetData($Label1,"Dragon")
        EndIf
    Case $Msg = $Button1
        IF $Selection = "FV_1" Then
            $mob = "Bear"
            Search1()
        ElseIf $Selection = "FV_2" Then
            $mob = "Dragon"
            Search1()
        EndIf
    Case $Msg = $Button2
            Exit
    Case $Msg = $GUI_EVENT_CLOSE
        Exit
    EndSelect
WEnd
EndFunc

Func Search1()
    Sleep(1000)
    $Text1 = ControlGetText($Title,"","[CLASS:RichEdit20A; INSTANCE:2]")
    $Trim1 = StringRight($Text1, 300)
    MsgBox("","",$mob)
    $a = StringInStr($Trim1, $mob & " is standing here.")
    If $a NOT= 0 Then
        ControlClick($Title,"","[CLASS:Button; INSTANCE:31]")
        ControlClick($Title,"","[CLASS:Button; INSTANCE:29]","Left",2)
        Sleep(3000)
        ControlClick($Title,"","[CLASS:Button; INSTANCE:28]","Left",2)
        $1 = 1
        Search2()       
    Else
    EndIf
    Sleep(100)
EndFunc

Share this post


Link to post
Share on other sites
Danny35d

You declare $mob for the main part of the script, but inside Search1() function you are using $mob which it hasn't been declare. You have two choice:

1) At the beging of the script add Global $mob

2) Change function Search1() to Search1($mob)


AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line

Share this post


Link to post
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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.