Jump to content

Multi Part Script, Need Help!


Recommended Posts

The following is many issues i have been having with my script, with explanations of what i wish it was doing, followed by the script. If anyone has the time to review my script and read my list of errors, and post back with some fixes it would be greatly appreciated :).

  • : I would like the GUI to start up as soon as the script is started and not have to have a hot key.
  • : The Func BgGUI() is supposed to SET the $killer variable for the whole time the program is running to use at a latter time, it is currently in a function and i don't think that it should be, or something.
  • : The BgGUI() function is triggering the function that the $killer variable is set to, it is not supposed to trigger it only set $killer = to it for future use in the script.
  • : If the $killer is appropriately defined it will later call its respective function during the main, start() which is ment to cycle throught the whole program runtime. The $killer is not currently being defined to my knowledge and at this point is not jumping to its respective function(). I have only created the function Wsg() just for test purposes but it is not triggered in this process.
  • : I believe Res() and the final step within WSG() will work to where when those pixels are detected it will exit the WSG() function loop and go back to the top of start(), after sleeping of course.
  • : Please also check for any other errors within the script that may be throwing the above "hoped" process off. Thanks, Brandon S

My Script: WARNING 140 LINES LONG....Don't let this scare you :)

#include <GUIConstants.au3>

AutoItSetOption("WinTitleMatchMode", 4)

Global $handle = WinGetHandle("classname=GxWindowClassD3d")
Global $show = 0, $Color = 0x6a0706, $Enter = 0xEE1400, $Killer = ""

HotKeySet("{F8}", "BgGUI") ;<========== ?!!?! Want to Rid of this !??!
HotKeySet("{F9}", "Start")
HotKeySet("{F10}", "Stop")


#Region ### START Koda GUI section ### Form=c:\users\brandon\desktop\autoit\queueing bgbot\gui\battle ground selector.kxf
$Form1_1 = GUICreate("Battle Ground Selector", 471, 101, -1, -1)
GUISetBkColor(0x0000FF)
$WSG = GUICtrlCreateButton("Warsong Gulch", 8, 32, 110, 40, 0)
GUICtrlSetFont(-1, 8, 400, 0, "Verdana")
$AV = GUICtrlCreateButton("Alterac Valley", 122, 32, 110, 40, 0)
GUICtrlSetFont(-1, 8, 400, 0, "Verdana")
$AB = GUICtrlCreateButton("Arathi Basin", 237, 32, 110, 40, 0)
GUICtrlSetFont(-1, 8, 400, 0, "Verdana")
$EOTS = GUICtrlCreateButton("Eye of the Storm", 351, 32, 110, 40, 0)
GUICtrlSetFont(-1, 8, 400, 0, "Verdana")
$Bottom = GUICtrlCreateLabel("World of Warcraft Battleground Automation Bot", 120, 80, 226, 17)
$Title = GUICtrlCreateLabel("Select Which Battleground You Wish to Enter:", 80, 8, 298, 19)
GUICtrlSetFont(-1, 8, 800, 0, "MS Reference Sans Serif")
GUICtrlSetColor(-1, 0x800000)
GUISetState(@SW_HIDE)
#EndRegion ### END Koda GUI section ###

While 1
    Sleep(20)
WEnd

Func BgGUI()   ;<============ ?!?! Should this even be a function !?!?
    GUISetState(@SW_SHOW, $Form1_1)
    While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $GUI_EVENT_CLOSE
                ExitLoop
            Case $WSG
                GUISetState(@SW_HIDE, $Form1_1)
                $Killer = WSG()                 ;<============ ?!?! Should get the variavle $killer as WSG() when $WSG is pressed, not start WSG()
                ExitLoop
            Case $AV
                GUIsetState(@SW_HIDE, $Form1_1)
                $Killer = AV()
                ExitLoop
            Case $AB
                GUISetState(@SW_HIDE, $Form1_1)
                $Killer = AB()
                ExitLoop
            Case $EOTS
                GUISetState(@SW_HIDE, $Form1_1)
                $Killer = EOTS()
                ExitLoop
            Case $Bottom
            Case $Title
        EndSwitch
    WEnd
    GUISetState(@SW_HIDE, $Form1_1)
    start()
EndFunc  

    
    Func start()                        ;<====== Before adding the GUI from Join() to Enter() worked great, this is good to go.
    
    While 1     
        Global $show = 0
        Global $Color = 0x6a0706
        Join()
        Sleep(5000)
        Enter()
        Sleep(20000)
        Call($killer)       ;<==== ?!?! this correct ?!?!
        Sleep(20000)
        If $show > 0 then ExitLoop
      WEnd
    EndFunc
    
    
    Func Join()
        MouseClick("Right", 652, 421, 1, 0)
        Sleep(5000)
        $Coords = PixelSearch(180, 510, 328, 550, $Color, 10)
        If isArray($Coords) then
        MouseClick("Left",$Coords[0], $Coords[1],1,1)
        EndIf
    EndFunc
    
    Func Enter()
        $boolean = 0
        While $boolean = 0
        $Coords = PixelSearch(472, 192, 640, 222, $Color, 10)
        Sleep(2000)
        $boolean = isArray($Coords)
        WEnd
        MouseClick("Left",$Coords[0], $Coords[1],1,1)
    EndFunc
    
    Func WSG()                                   ;<====== test junk thrown in here to test out its functionality in game
        $exit = 0                               ;<====== and to see if the $killer was working
        While $exit = 0
            Sleep(5000)
            Send("{Up Down}")
            Sleep(500)
            Send("{Up Up}")
            Sleep(10000)
            Res()
            Send("{Down Down}")
            Sleep(500)
            Send("{Down Up}")
            Res()
            $Coords = PixelSearch(571, 543, 769, 573, $Color, 10)
            Sleep(1000)
            $exit = isArray($Coords)         ;<===== Will this exit the loop upon pixel discovery and will it send it back to Send("{Up... After one search?
        WEnd    
            MouseClick("Left",$Coords[0], $Coords[1],1,1)
    EndFunc
    
    Func Res()
        $Coords = PixelSearch(557, 178, 718, 207, $Color, 10)
        If isArray($Coords) then
        MouseClick("Left",$Coords[0], $Coords[1],1,1)
        Sleep(25000)
        EndIf
    EndFunc
    
    Func stop()
        Global $show = 1
        WinSetState("World of Warcraft", "", @SW_SHOW)
        WinSetState("World of Warcraft", "", @SW_MAXIMIZE)
        WinActivate($handle, "")
    EndFunc

I know this is ALOT of questions but anyone who can help, even just a bit, or if someone can work on it and fix as many errors as they can or just tell me how to! Any help is appreciated, Thanks in Advance

...will never learn all there is to know about autoit, no worries...i came to the forums :)

Link to comment
Share on other sites

#include <GUIConstants.au3>

AutoItSetOption("WinTitleMatchMode", 4)

Global $handle = WinGetHandle("classname=GxWindowClassD3d")
Global $show = 0, $Color = 0x6a0706, $Enter = 0xEE1400, $Killer = ""

HotKeySet("{F9}", "Start")
HotKeySet("{F10}", "Stop")

#Region ### START Koda GUI section ### Form=c:\users\brandon\desktop\autoit\queueing bgbot\gui\battle ground selector.kxf
$Form1_1 = GUICreate("Battle Ground Selector", 471, 101, -1, -1)
GUISetBkColor(0x0000FF)
$WSG = GUICtrlCreateButton("Warsong Gulch", 8, 32, 110, 40, 0)
GUICtrlSetFont(-1, 8, 400, 0, "Verdana")
$AV = GUICtrlCreateButton("Alterac Valley", 122, 32, 110, 40, 0)
GUICtrlSetFont(-1, 8, 400, 0, "Verdana")
$AB = GUICtrlCreateButton("Arathi Basin", 237, 32, 110, 40, 0)
GUICtrlSetFont(-1, 8, 400, 0, "Verdana")
$EOTS = GUICtrlCreateButton("Eye of the Storm", 351, 32, 110, 40, 0)
GUICtrlSetFont(-1, 8, 400, 0, "Verdana")
$Bottom = GUICtrlCreateLabel("World of Warcraft Battleground Automation Bot", 120, 80, 226, 17)
$Title = GUICtrlCreateLabel("Select Which Battleground You Wish to Enter:", 80, 8, 298, 19)
GUICtrlSetFont(-1, 8, 800, 0, "MS Reference Sans Serif")
GUICtrlSetColor(-1, 0x800000)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit ; ************  exit the program
        Case $WSG
            $Killer = "WSG" ;<= *********** Fixed
            ExitLoop
        Case $AV
            $Killer = "AV"
            ExitLoop
        Case $AB
            $Killer = "AB"
            ExitLoop
        Case $EOTS
            $Killer = "EOTS"
            ExitLoop
        Case $Bottom
        Case $Title
    EndSwitch
WEnd

GUIDelete($Form1_1)
;start() ; ************* press start (F9) to go or remove the comment to start automatically

While 1
    Sleep(20)
WEnd

Func start() ;<====== Before adding the GUI from Join() to Enter() worked great, this is good to go.

    While 1
        $show = 0 ; ***************** DO NOT USE GLOBAL IN A LOOP - This will reset the value of $show to 0 - at top of script too
        ;Global $Color = 0x6a0706 ; ***************** DO NOT USE GLOBAL IN A LOOP - This was already done at the top of this script
        Join()
        Sleep(5000)
        Enter()
        Sleep(20000)
        Call($Killer) ;<==== ?!?! this correct ?!?! ***  yes, I think it is now
        Sleep(20000)
        If $show > 0 Then ExitLoop
    WEnd
EndFunc   ;==>start

Func Join()
    MouseClick("Right", 652, 421, 1, 0)
    Sleep(5000)
    $Coords = PixelSearch(180, 510, 328, 550, $Color, 10)
    If IsArray($Coords) Then
        MouseClick("Left", $Coords[0], $Coords[1], 1, 1)
    EndIf
EndFunc   ;==>Join

Func Enter()
    $boolean = 0
    While $boolean = 0
        $Coords = PixelSearch(472, 192, 640, 222, $Color, 10)
        Sleep(2000)
        $boolean = IsArray($Coords)
    WEnd
    MouseClick("Left", $Coords[0], $Coords[1], 1, 1)
EndFunc   ;==>Enter

Func WSG() ;<====== test junk thrown in here to test out its functionality in game
    $exit = 0 ;<====== and to see if the $killer was working
    While $exit = 0
        Sleep(5000)
        Send("{Up Down}")
        Sleep(500)
        Send("{Up Up}")
        Sleep(10000)
        Res()
        Send("{Down Down}")
        Sleep(500)
        Send("{Down Up}")
        Res()
        $Coords = PixelSearch(571, 543, 769, 573, $Color, 10)
        Sleep(1000)
        $exit = IsArray($Coords) ;<===== Will this exit the loop upon pixel discovery ** YES, then it will do the mouseclick below
        ; and will it send it back to Send("{Up... After one search? - YES, after the sleep above it  Sleep(5000)
    WEnd
    MouseClick("Left", $Coords[0], $Coords[1], 1, 1)
EndFunc   ;==>WSG

Func AV()
    MsgBox(0x0, "Attack", "AV   ")
EndFunc   ;==>AV

Func AB()
    MsgBox(0x0, "Attack", "AB   ")
EndFunc   ;==>AB

Func EOTS()
    MsgBox(0x0, "Attack", "EOTS   ")
EndFunc   ;==>EOTS

Func Res()
    $Coords = PixelSearch(557, 178, 718, 207, $Color, 10)
    If IsArray($Coords) Then
        MouseClick("Left", $Coords[0], $Coords[1], 1, 1)
        Sleep(25000)
    EndIf
EndFunc   ;==>Res

Func stop()
    Global $show = 1
    WinSetState("World of Warcraft", "", @SW_SHOW)
    WinSetState("World of Warcraft", "", @SW_MAXIMIZE)
    WinActivate($handle, "")
EndFunc   ;==>stop

8)

NEWHeader1.png

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