Jump to content

Array declaration dont want to work


 Share

Recommended Posts

Hi,

Im very new to AutoIt so i hope you can help me. I tryed to script a simple application, you just should be able to Pick a Color and a Coordinate at two spots, so if the color is visible at the first Spot it moves the Mouse to the second Spot. Is the second Color visible, it just should do a leftclick.

But anyway, I have some Errors i can't get Fixed. I don't know any further.

The Code:

;GUI
#include <GUIConstantsEX.au3>
#include <Misc.au3>
Global $aCord, $hTimer, $iColor
Global $aCord[2], $hTimer
Global $bCord, $pTimer, $sColor
Global $bCord[2], $pTimer
opt("GUIOnEventMode", 1)
GUICreate("Gamble Bot", 600, 600)
GUIsetonevent($GUI_EVENT_CLOSE, "close")
GUISetOnEvent($GUI_EVENT_MINIMIZE, "minimize")
GUISetState(@SW_SHOW)
$Group1             = GUICtrlCreateGroup ("Operation 1", 5, 5, 500, 65)
$IDGetInput_1       = GUICtrlCreateButton("Get Input 1", 20, 20, 100, 20)
$IDGetInput_2       = GUICtrlCreateButton("Get Input 2", 20, 40, 100, 20)
$IDOperationsLabel  = GUICtrlCreateLabel ("Number of Pixel Searches:", 20, 80, 200, 20)
$IDOpterationsCount = GUICtrlCreateInput ("1", 200, 80, 50, 20)
$IDOperationsDelay  = GUICtrlCreateLabel ("Delay Time:", 20, 100, 200, 20)
$IDOperationsDelayS = GUICtrlCreateLabel ("ms", 275, 100, 200, 20)
$IDOpterationsDelay = GUICtrlCreateInput ("500", 200, 100, 50, 20)
$IDGamble           = GUICtrlCreateButton("Gamble", 200, 550, 100, 20)
$IDExit             = GUICtrlCreateButton("Exit", 300, 550, 100, 20)
GUICtrlSetOnEvent($IDGetInput_1, "GetInput_1")
GUICtrlSetOnEvent($IDGetInput_2, "GetInput_2")
GUIctrlsetonEvent($IDGamble, "Gamble")
GUIctrlsetonEvent($IDExit, "_msg_2")
While 1
    Sleep(1000)
WEnd
;
;Scan Coords & Color
;
Func GetInput_1()
MsgBox(0,"Choosen Color:", SetColor_1("Left click to define Scan Color"))
$aArray = SetCoord_1("left click to define Scan Coordinate")
MsgBox(0,"Choosen Coordinate","X: "&$aArray[0] & " Y: " & $aArray[1])
EndFunc

Func SetColor_1($sText, $iKey = 01, $bHex = True, $iTimeout = 5000)
    MsgBox(0, "", $sText, 5)
;
    $hTimer = TimerInit()
    Do
        If _IsPressed($iKey) Then
            $aCord = MouseGetPos()
            $iColor = PixelGetColor($aCord[0],$aCord[1])
            If $bHex Then Return Hex($iColor)
            Return $iColor
        EndIf
    Until TimerDiff($hTimer) >= $iTimeout
Return SetError(1,"",0)
EndFunc   ;==>_SetColor
;
Func SetCoord_1($sText, $iKey = 01, $iTimeout = 5000)
    MsgBox(0, "", $sText, 5)

    $hTimer = TimerInit()
    Do
        If _IsPressed($iKey) Then
            $aCord[0] = MouseGetPos(0)
            $aCord[1] = MouseGetPos(1)
            Return $aCord
        EndIf
    Until TimerDiff($hTimer) >= $iTimeout
    Return SetError(1,"",0)
EndFunc   ;==>_SetCoord
;
;Click Coords & Color
;
Func GetInput_2()
MsgBox(0,"Choosen Color:", SetColor_2("Left click to define Click Color"))
$bArray = SetCoord_2("left click to define Click Coordinate")
MsgBox(0,"Choosen Coordinate","X: "&$bArray[0] & " Y: " & $bArray[1])
EndFunc
;
Func SetColor_2($xText, $oKey = 01, $iHex = True, $zTimeout = 5000)
    MsgBox(0, "", $xText, 5)

    $pTimer = TimerInit()
    Do
        If _IsPressed($oKey) Then
            $bCord = MouseGetPos()
            $sColor = PixelGetColor($bCord[0],$bCord[1])
            If $iHex Then Return Hex($sColor)
            Return $sColor
        EndIf
    Until TimerDiff($pTimer) >= $zTimeout
    Return SetError(1,"",0)
EndFunc   ;==>_SetColor
;
Func SetCoord_2($xText, $oKey = 01, $zTimeout = 5000)
    MsgBox(0, "", $xText, 5)

    $pTimer = TimerInit()
    Do
        If _IsPressed($oKey) Then
            $bCord[0] = MouseGetPos(0)
            $bCord[1] = MouseGetPos(1)
            Return $bCord
        EndIf
    Until TimerDiff($pTimer) >= $zTimeout
    Return SetError(1,"",0)
EndFunc   ;==>_SetCoord
;
; Color Scan Block & Mouse Move
;
Func Gamble()
    Global $iCount = 0
    Do
        $iCount += 1
        PixelSearch ($aArray[0], $aArray[1], $iColor, 10)
        If Not @error Then
            MouseMove($bArray[0], $bArray[1], 0)
            ExitLoop
        EndIf
    Until $iCount = $IDOpterationsCount ;Wiederholt die Schleife bis so oft wie es eingegeben wurde
;
; Color Verify and Mouse Click
;
    Global $oCount = 0
    Do
        $oCount += 1
    PixelSearch ($bArray[0], $bArray[1], $sColor, 10)
            If Not @error Then
                MouseClick("left")
            ExitLoop
        EndIf
    Until $oCount = $IDOpterationsCount ;Wiederholt die Schleife bis so oft wie es eingegeben wurde
    If @error Then
        MsgBox(0,"","No Matching Color Found!")
    EndIf
EndFunc
;
; Application Minimize & Exit Controlls
;
Func _msg_2()
    MsgBox(0, "Exit", "Application Exits now")
Exit
EndFunc
Func close()
    Exit
EndFunc
Func minimize()
EndFunc
;************************************************
;* Declaring Variable                           *
;* While between Mouse Move and Click Block?    *
;* Does Delay and Operation count work?         *
;************************************************

The AutoIT Error log after Syntax check:

>C:\Program Files (x86)\AutoIt3\SciTE\..\au3check.exe "C:\Users\Daedlus\Desktop\GambleBot\GambleBotX.au3"
AutoIt3 Syntax Checker v1.54.8  Copyright (c) Tylo 2007

C:\Users\Daedlus\Desktop\GambleBot\GambleBotX.au3(111,32) : WARNING: $aArray: possibly used before declaration.
        PixelSearch ($aArray[0],
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Users\Daedlus\Desktop\GambleBot\GambleBotX.au3(111,57) : ERROR: PixelSearch() [built-in] called with wrong number of args.
        PixelSearch ($aArray[0], $aArray[1], $iColor, 10)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Users\Daedlus\Desktop\GambleBot\GambleBotX.au3(113,33) : WARNING: $bArray: possibly used before declaration.
            MouseMove($bArray[0],
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Users\Daedlus\Desktop\GambleBot\GambleBotX.au3(123,53) : ERROR: PixelSearch() [built-in] called with wrong number of args.
    PixelSearch ($bArray[0], $bArray[1], $sColor, 10)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Users\Daedlus\Desktop\GambleBot\GambleBotX.au3(111,32) : ERROR: $aArray: undeclared global variable.
        PixelSearch ($aArray[0],
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Users\Daedlus\Desktop\GambleBot\GambleBotX.au3 - 3 error(s), 2 warning(s)
>Exit code: 2    Time: 0.216

Thanks!!!

Link to comment
Share on other sites

This forum does not support games bots.

All by me:

"Sometimes you have to go back to where you started, to get to where you want to go." 

"Everybody catches up with everyone, eventually" 

"As you teach others, you are really teaching yourself."

From my dad

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

 

WindowsError.gif

WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF

AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send

StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2

AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit  Docs

SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF

Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with $__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

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...