Jump to content

Pausing mid script?


 Share

Recommended Posts

Hi, i have a bot here that works fairly well, however i was wondering what is the best way to pause the script during one of the searches? i tried to do it with the guistat func but it doesn't seem to be working.

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

$FV_1 = "C:\Documents and Settings\Admin\Desktop\Rev bot\FV_1.bmp"
$FV_2 = "C:\Documents and Settings\Admin\Desktop\Rev bot\FV_2.bmp"
$Title = "(Tank)"
$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()
            FV_1()
        ElseIf $Selection = "FV_2" Then
            $mob = "Dragon"
            Search1()
            FV_2()
        EndIf
    Case $Msg = $Button2
            Exit
    Case $Msg = $GUI_EVENT_CLOSE
        Exit
    EndSelect
WEnd
EndFunc

Func FV_1()
    While 1
    MoveLEFT()
    MoveDOWN()
    MoveLEFT()
    MoveRIGHT()
    MoveDOWN()
    MoveRIGHT()
    MoveUP()
    MoveUP()
    WEnd
EndFunc

Func FV_2()
    While 1
    MoveRIGHT()
    MoveRIGHT()
    MoveDOWN()
    MoveLEFT()
    MoveUP()
    MoveLEFT()
    WEnd
EndFunc

Func GuiStat()
    $Msg = GUIGetMsg()
    Select
    Case $Msg = $Button2
        Exit
    EndSelect
EndFunc

Func Search1()
    Sleep(1000)
    $Text1 = ControlGetText($Title,"","[CLASS:RichEdit20A; INSTANCE:2]")
    $Trim1 = StringRight($Text1, 300)
    $a = StringInStr($Trim1, $mob & " is 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()
        GuiStat()
    Else
    EndIf
    Sleep(100)
EndFunc

Func Search2()
    While $1 > 0
        $Text2 = ControlGetText($Title,"","[CLASS:RichEdit20A; INSTANCE:2]")
        $Trim2 = StringRight($Text2, 200)
        $b = StringInStr($Trim2, "You gain")
        $Trim4 = StringRight($Text2, 2000)
        $d = StringInStr($Trim4, "slain by")
        If $b NOT= 0 Then
            $1 = 0
        EndIf
        If $d NOT= 0 Then
            MsgBox("","","Dead")
            Exit
        EndIf
    WEnd
EndFunc

Func Chat()
    $Text3 = ControlGetText($Title,"","[CLASS:RichEdit20A; INSTANCE:2]")
    $Trim3 = StringRight($Text3, 1000)
    $Trim4 = StringRight($Text3, 2000)
    $c = StringInStr($Trim3, "tells")
    $d = StringInStr($Trim4, "You are dead")
    If $c OR $d NOT= 0 Then
        MsgBox("","","Bot Stopped")
        Exit
    EndIf
EndFunc

Func MoveUP()
    Chat()
    ControlClick($Title,"",1023)
    Search1()
EndFunc

Func MoveDOWN()
    Chat()
    ControlClick($Title,"",1024)
    Search1()
EndFunc

Func MoveLEFT()
    Chat()
    ControlClick($Title,"",1026)
    Search1()
EndFunc

Func MoveRight()
    Chat()
    ControlClick($Title,"",1025)
    Search1()
EndFunc
Link to comment
Share on other sites

i did this, but it didn't seem to work

Func GuiStat()
    While 1
    $Msg = GUIGetMsg()
    Select
    Case $Msg = $Button2
        Exit
    EndSelect
    WEnd
EndFunc
Link to comment
Share on other sites

i did this, but it didn't seem to work

Func GuiStat()
    While 1
    $Msg = GUIGetMsg()
    Select
    Case $Msg = $Button2
        Exit
    EndSelect
    WEnd
EndFunc
Haven't read through your script, but could be it replacing Exit with ExitLoop? Because Exit will _always_ exit your script, and the title says pausing, so i think this may be it Edited by koekje
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...