Jump to content
Sign in to follow this  
EscapeTheFate

stuck, script just stops

Recommended Posts

EscapeTheFate

#include <IE.au3>

#include <GUIConstants.au3>

#Include <GuiStatusBar.au3>

#include <String.au3>

_IEErrorHandlerRegister("MyErrFunc")

Opt("WinTitleMatchMode", 2)

Func MyErrFunc()

EndFunc

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

$g_szVersion = ":)"

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

Global $Paused

global $MinValue = IniRead("Shant.ini", "defaults", "MinValue", "")

global $MaxValue = IniRead("Shant.ini", "defaults", "MaxValue", "")

global $Potionname = IniRead("Shimlar.ini", "defaults", "Potionname", "")

global $iniread = IniRead(@HomeDrive & "\tempdll.ini", "Return", "SHERRACC", "")

global $delay = IniRead("Shant.ini", "defaults", "fdelay", "")

global $delaymove = IniRead("Shant.ini", "defaults", "mdelay", "")

HotKeySet("{F8}", "Terminate")

HotKeySet("{F9}", "TogglePause")

HotKeySet("{F8}", "captureEsc")

Func Terminate()

Exit 0

EndFunc

Func captureEsc()

Terminate()

HotKeySet("{F8}")

Send("{F8}")

HotKeySet("{F8}", "captureEsc")

EndFunc

Func TogglePause()

$Paused = NOT $Paused

While $Paused

AdlibDisable()

sleep(100)

ToolTip('Script is paused.',0,0)

WEnd

ToolTip('')

EndFunc

AutoItWinSetTitle($g_szVersion)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

Func Attach()

$oIE = _IEAttach("|:.Shantara Online .:|")

If Not $oIE Then

$m = MsgBox(1,"Failed.", "Failed to find window. Try again?")

If $m = 1 Then

Attach()

Else

Exit

EndIf

EndIf

EndFunc

Opt("GUIOnEventMode", 1)

;~ Opt("GUIDataSeparatorChar", "|") ; this is the default, no need for this line

GUICreate("Chris's Shant Script " & $g_szVersion, 250, 200)

GUISetBkColor (0x00ff00)

GUISetState(@SW_SHOW)

GUISetOnEvent($GUI_EVENT_CLOSE, "Terminate")

$background = GUICtrlCreatePic("AU3-2.bmp", 0, 0, 450, 400)

GUICtrlSetState($background, $GUI_DISABLE)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;Play Sound;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

$btn_start = GUICtrlCreateButton("Start ", 10, 30, 80, 30, BitOR($GUI_SS_DEFAULT_BUTTON, $BS_DEFPUSHBUTTON))

GUICtrlSetOnEvent($btn_start, "Start");~ GUICtrlSetOnEvent($btn_start, "FightAgain") ;changed this to call function "Start", with your set up, it would only do the FightAgain once.

;;;;;;;;

;Create Exit Button

$btn_exit = GUICtrlCreateButton("Exit", 10, 70, 80, 30)

GUICtrlSetOnEvent($btn_exit, "Terminate")

;;;;;;;;;

$label_min = GUICtrlCreateLabel("Min Value: ", 10, 110, 80, 20)

GUICtrlSetBkColor($label_min, -2)

$input_min = GUICtrlCreateInput("", 10, 130, 80, 20)

GUICtrlSetTip($input_min, "Minimum Value To Pick Up")

;;;;;;;;;;

$label_max = GUICtrlCreateLabel("Max Value: ", 10, 150, 80, 20)

GUICtrlSetBkColor($label_max, -2)

$input_max = GUICtrlCreateInput("", 10, 170, 80, 20)

GUICtrlSetTip($input_max, "Maximum Value To Pick Up")

;;;;;

$label_Potions = GUICtrlCreateLabel("Potion to pick up: ", 95, 110, 120, 20)

GUICtrlSetBkColor($label_Potions, -2)

$input_Potions = GUICtrlCreateInput("", 95, 130, 140, 20)

GUICtrlSetTip($input_Potions, "Name of potion")

;;;;;;;;

;Create Fight Delay Input

$label_fdelay = GUICtrlCreateLabel("Fdelay : ", 90, 10, 80, 20, $SS_RIGHT)

GUICtrlSetBkColor($label_fdelay, -2)

$input_fdelay = GUICtrlCreateInput("", 170, 7, 40, 20)

GUICtrlSetTip($input_fdelay, "Input fight delay time in milliseconds.")

;Create Move Delay Input

$label_mdelay = GUICtrlCreateLabel("Mdelay : ", 90, 30, 80, 20, $SS_RIGHT)

GUICtrlSetBkColor($label_mdelay, -2)

$input_mdelay = GUICtrlCreateInput("", 170, 27, 40, 20)

GUICtrlSetTip($input_mdelay, "Input move delay time in milliseconds.")

$oIE = _IEAttach("|:.Shantara Online .:|"); this is done already, can be deleted

while 1

sleep(1) ;idle around and wait for the press of the start button (or exit)

WEnd

Func FightAgain()

sleep($delay)

$oFrame = _IEFrameGetObjByName ($oIE, 0)

$oForm = _IEFormGetObjByName($oFrame, "FightAgain")

_IEFormSubmit($oForm)

_IELoadWait($oIE)

EndFunc

func Attack()

sleep($delay)

$oFrame = _IEFrameGetObjByName ($oIE, 0)

$oForm = _IEFormGetObjByName($oFrame, "baction")

_IEFormSubmit($oForm)

_IELoadWait($oIE)

EndFunc

Func TakeItem($itemSlot = 1)

If Not IsObj($oIE) Then

__IEErrorNotify ("Error", "fornicate", "$_IEStatus_InvalidDataType")

SetError($_IEStatus_InvalidDataType, 1)

Return 0

EndIf

;

If Not __IEIsObjType ($oIE, "documentContainer") Then

__IEErrorNotify ("Error", "fornicate", "$_IEStatus_InvalidObjectType")

SetError($_IEStatus_InvalidObjectType, 1)

Return 0

EndIf

;

$oIE.navigate2 ("java script:top.Game.TakeItem.which.value = " & $itemSlot & " top.Game.TakeItem.submit()")

If 1 Then

SetError(@error)

EndIf

sleep(5)

;~ $oIE.navigate2 ("java script:top.Game.TakeItem.submit()")

If 1 Then

SetError(@error)

EndIf

SetError($_IEStatus_Success)

EndFunc

Func CheckForPots()

$oStatsFrame = _IEFrameGetObjByName($oIE, 0) ; object/frame stat frame

$statsClip = _IEDocReadHTML($oStatsFrame)

$statsclip2 = StringStripCR(_IEBodyReadText($oStatsFrame))

Dim $itemname

$value = _StringBetween($statsclip,"<B>Value:</B> ","<BR><B>")

$itemname = _StringBetween($statsclip,"<B><U>" & @CRLF & "<CENTER>","</CENTER>")

If StringInStr($statsclip,"Item Found!",1,1) Then

;~ MsgBox(1,"1",$itemname[0])

if StringInStr($itemname[0],"Health",1,1) Then

;~ MsgBox(1,"1",$value[0])

TakeItem("1")

EndIf

EndIf

If StringInStr($statsclip,"Item Found!",1,2) Then

;~ MsgBox(1,"2",$itemname[0] & $itemname[1])

if StringInStr($itemname[1],"Health",1,1) Then

;~ MsgBox(1,"2",$value[1])

TakeItem("2")

EndIf

Else

;~ MsgBox(1,"","No Item")

EndIf

EndFunc

Func Start() ;added this, by calling start, it will start repeating

$delay = GUICtrlRead($input_fdelay)

GUIdelete()

while 1

FightAgain()

Attack()

CheckForPots()

WEnd

EndFunc ;added this

Share this post


Link to post
Share on other sites
PsaltyDS

Does it wait in the While loop properly for you to do something?

while 1
sleep(1) ;idle around and wait for the press of the start button (or exit)
WEnd

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

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  

×