Jump to content
Sign in to follow this  
d0n

Pausing mid script?

Recommended Posts

d0n

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

Share this post


Link to post
Share on other sites
dantay9

Put the contents of guistat into a while loop. When the criteria is met, exit the loop and continue the script.


[font="Verdana"] [size="2"]"[/size][/font]Failure is not an option -- it comes packaged with Windows"[font="Verdana"][size="2"] Gecko Web Browser[/size][/font][font="Verdana"][size="2"], [/size][/font][font="Verdana"][size="2"]Yahtzee![/size][/font][font="Verdana"][size="2"], Toolbar Launcher (like RocketDock)[/size][/font][font="Verdana"][size="2"]Internet Blocker, Simple Calculator, Local Weather, Easy GDI+ GUI [/size][/font][font="Verdana"][size="2"]Triangle Solver, TCP File Transfer, [/size][/font][font="Verdana"][size="2"]Valuater's Autoit Wrappers[/size][/font][font="Verdana"][size="3"][size="2"][size="2"]OOP In AutoIt[/size][/size][/size][/font][font="Verdana"][size="2"][size="1"]Using Windows XP SP3, 1GB RAM, AMD Athlon Processor @ 2.1 GHzCheck me out at gadgets.freehostrocket.com[/size][/size][/font]

Share this post


Link to post
Share on other sites
d0n

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

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

Share this post


Link to post
Share on other sites
koekje

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

Share this post


Link to post
Share on other sites
d0n

na, i just want to either pause or exit mid script inside a loop

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  

×