Jump to content

Loop Until is not working for me =(


 Share

Recommended Posts

So I nearly have my script done but I can't seem to get my Loop Until functions to work (there are two). It is supposed to continue looping until the amount in the input box has been reached. I would just link the functions but just to keep this easy I will link the entire script in case there may be something worng, I have over looked this quite a few times and everything is fine as far as I can see.

#cs ----------------------------------------------------------------------------

 AutoIt Version: 3.3.0.0
 Author:Dazzled  myName

 Script Function: Makes prospecting, Jewelcrafting, and several other commands easy!
    Template AutoIt script.

#ce ----------------------------------------------------------------------------

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <ImageListConstants.au3>
#Include <GuiMenu.au3>
#include <GuiComboBoxEx.au3>
#include <GUIButton.au3>
#Include <GuiSlider.au3>
#include <IE.au3>
#include <SliderConstants.au3>
#include <StructureConstants.au3>

FileInstall("M:\Kevin\Autoit\Jewel Crafter\Icons\Disenchant.ico", @Scriptdir & "\Icons\Disenchant.ico")
FileInstall("M:\Kevin\Autoit\Jewel Crafter\Icons\Eternal Earth.ico", @Scriptdir & "\Icons\Eternal Earth.ico")
FileInstall("M:\Kevin\Autoit\Jewel Crafter\Icons\JC.ico", @Scriptdir & "\Icons\JC.ico")
FileInstall("M:\Kevin\Autoit\Jewel Crafter\Icons\Jewelcrafting.ico", @Scriptdir & "\Icons\Jewelcrafting.ico")
FileInstall("M:\Kevin\Autoit\Jewel Crafter\Icons\Saronite.ico", @Scriptdir & "\Icons\Saronite.ico")
FileInstall("M:\Kevin\Autoit\Jewel Crafter\Icons\Jewel Crafter.jpg", @Scriptdir & "\Icons\Jewel Crafter.jpg")

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

Global $Paused

#Region ### START Koda GUI section ### Form=C:\Users\Kevin\Desktop\Jewel Crafter\JewelCrafter.kxf
$Main = GUICreate("Jewel Crafter", 358, 287, -1, -1)
GUISetIcon(@Scriptdir & "\Icons\JC.ico")
GUISetBkColor(0x000000)
$Website = GUICtrlCreateButton("Website", 8, 256, 65, 25, 0)
GUICtrlSetCursor (-1, 0)
$Crafter = GUICtrlCreateButton("Crafter", 221, 177, 41, 41, BitOR($BS_ICON,$WS_GROUP))
GUICtrlSetImage(-1, @Scriptdir & "\Icons\Jewelcrafting.ico", -1)
GUICtrlSetCursor (-1, 0)
$Earth = GUICtrlCreateButton("Earth", 80, 177, 41, 41, BitOR($BS_ICON,$WS_GROUP))
GUICtrlSetImage(-1, @Scriptdir & "\Icons\Eternal Earth.ico", -1)
GUICtrlSetCursor (-1, 0)
$Saronite = GUICtrlCreateButton("Saronite", 80, 65, 41, 41, BitOR($BS_ICON,$WS_GROUP))
GUICtrlSetImage(-1, @Scriptdir & "\Icons\Saronite.ico", -1)
GUICtrlSetCursor (-1, 0)
$Enchant = GUICtrlCreateButton("Disenchant", 223, 65, 41, 41, BitOR($BS_ICON,$WS_GROUP))
GUICtrlSetImage(-1, @Scriptdir & "\Icons\Disenchant.ico", -1)
GUICtrlSetCursor (-1, 0)
$Input = GUICtrlCreateInput("10", 309, 237, 25, 21)
GUICtrlSetCursor (-1, 5)
$Input2 = GUICtrlCreateInput("0", 309, 123, 25, 21)
GUICtrlSetCursor (-1, 5)
$Input3 = GUICtrlCreateInput("20", 89, 123, 25, 21)
GUICtrlSetCursor(-1, 5)
$Combo = GUICtrlCreateCombo("Which item to D/E", 184, 123, 113, 25)
GUICtrlSetData(-1, "Bloodstone Band|Crystal Chalcedony Amulet|Crystal Citrine Necklace|Sun Rock Ring")
GUICtrlSetCursor (-1, 2)
$Combo2 = GUICtrlCreateCombo("Which item to craft?", 184, 237, 113, 25)
GUICtrlSetData(-1, "Bloodstone Band|Crystal Chalcedony Amulet|Crystal Citrine Necklace|Sun Rock Ring")
GUICtrlSetCursor (-1, 2)
$Label1 = GUICtrlCreateLabel("v3.0", 8, 0, 37, 34)
GUICtrlSetFont(-1, 14, 400, 0, "Papyrus")
GUICtrlSetColor(-1, 0x0000FF)
$Label2 = GUICtrlCreateLabel("Dazzled", 272, 260, 68, 31)
GUICtrlSetFont(-1, 14, 400, 0, "Pristina")
GUICtrlSetColor(-1, 0x00FF00)
$Label3 = GUICtrlCreateLabel("Saronite", 81, 105, 43, 17)
GUICtrlSetColor(-1, 0xFFFFFF)
$Label4 = GUICtrlCreateLabel("How many do" & @LF & "you have to" & @LF & "disenchant?", 280, 65, 69, 55)
GUICtrlSetColor(-1, 0x008000)
$Label5 = GUICtrlCreateLabel("Prospecting", 57, 36, 94, 28)
GUICtrlSetFont(-1, 14, 400, 2, "Harlow Solid Italic")
GUICtrlSetColor(-1, 0x00FF00)
$Label5 = GUICtrlCreateLabel("Earth", 86, 221, 29, 17)
GUICtrlSetColor(-1, 0xFFFFFF)
$Label6 = GUICtrlCreateLabel(" Eternal Converter", 30, 148, 148, 28)
GUICtrlSetFont(-1, 14, 400, 2, "Harlow Solid Italic")
GUICtrlSetColor(-1, 0x00FF00)
$Label7 = GUICtrlCreateLabel(" Disenchant", 191, 36, 97, 28)
GUICtrlSetFont(-1, 14, 400, 2, "Harlow Solid Italic")
GUICtrlSetColor(-1, 0x00FF00)
$Label8 = GUICtrlCreateLabel("Disenchanter", 211, 105, 67, 17)
GUICtrlSetColor(-1, 0xFFFFFF)
$Label9 = GUICtrlCreateLabel(" Crafter", 207, 148, 65, 28)
GUICtrlSetFont(-1, 14, 400, 2, "Harlow Solid Italic")
GUICtrlSetColor(-1, 0x00FF00)
$Label10 = GUICtrlCreateLabel("How many?", 292, 205, 60, 17)
GUICtrlSetColor(-1, 0x008000)
$Label11 = GUICtrlCreateLabel('Item', 230, 218, 25, 17)
GUICtrlSetColor(-1, 0x008000)
$Label12 = GUICtrlCreateLabel("<--- Click to go to my thread", 80, 261, 150, 48)
GUICtrlSetColor(-1, 0x008000)
$Label13 = GUICtrlCreateLabel("Opacity", 280, 27, 42, 17)
GUICtrlSetColor(-1, 0x008000)
$Pic1 = GUICtrlCreatePic(@Scriptdir & "\Icons\Jewel Crafter.jpg", 97, 2, 162, 34, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
Global $slider1 = GUICtrlCreateSlider(250, 5, 100, 20)
GUICtrlSetBkColor(-1,0)
GUICtrlSetLimit(-1, 255, 126)
GUICtrlSetData(-1, 255)
GUISetState()
$hWnd = WinGetHandle("[CLASS:Autoit v3 GUI]")
$hOre = GUICtrlRead($Input3)/5
GUISetState(@SW_SHOW, $Main)
#EndRegion ### END Koda GUI section ###

WinSetOnTop("[CLASS:AutoIt v3 GUI]", "", 1)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $nMsg = $slider1
            WinSetTrans($Main, "", GUICtrlRead($slider1))
            sleep (100)
        Case $Website
            ShellExecute("http://www.mmowned.com/forums/bots-programs/263100-jewel-crafter-auto-profession.html")
        Case $Saronite
            WinActivate('[TITLE:Untitled - Notepad]')
            WinWaitActive('[TITLE:Untitled - Notepad]')
            Sendinformation()
        Case $Enchant
            WinActivate('[TITLE:Untitled - Notepad]')
            WinWaitActive('[TITLE:Untitled - Notepad]')
            Sendinformation2()
        Case $Crafter
            WinActivate('[TITLE:Untitled - Notepad]')
            WinWaitActive('[TITLE:Untitled - Notepad]')
            Sendinformation3()
        Case $Earth
            WinActivate('[TITLE:Untitled - Notepad]')
            WinWaitActive('[TITLE:Untitled - Notepad]')
            Sendinformation4()
    EndSwitch
WEnd

Func Sendinformation()
    Local $h_Ore, $times
    While 1
    Sleep(200)
    Send('{ENTER}')
    Sleep(200)
    Send('/cast prospecting')
    Sleep(200)
    Send("{ENTER}")
    Sleep(500)
    Send('{ENTER}')
    Sleep(200)
    Send('/use Saronite Ore')
    Sleep(200)
    Send("{ENTER}")
    Sleep(3000)
If $times = $hOre Then ExitLoop
    WEnd
EndFunc

Func sendinformation2()
    While 1
    $times2 = 1
    Sleep(200)
    Send('{ENTER}')
    Sleep(200)
    Send('/cast disenchant')
    Sleep(200)
    Send('{ENTER}')
    Sleep(100)
    Send('{ENTER}')
    Sleep(200)
    Send('/use ' & GUICtrlRead($Combo))
    Sleep(200)
    Send('{ENTER}')
    Sleep(3500)
If $times2 = $Input2 Then ExitLoop
    WEnd
EndFunc

Func Sendinformation3()
    Sleep(200)
    Send('{ENTER}')
    Sleep(200)
    Send('/run CloseTradeSkill()')
    Send('{ENTER}')
    Sleep(500)
    Send('{ENTER}')
    Sleep(200)
    Send('/cast Jewelcrafting')
    Sleep(500)
    Send('{ENTER}')
    Sleep(500)
    Send('{ENTER}')
    Sleep(200)
    Send('/run local s for i=1,GetNumTradeSkills() do s=GetTradeSkillInfo(i) if (s==' & GUICtrlRead($Combo2) & ') then DoTradeSkill(i,' & GUICtrlRead($Input) & ') end end')
    Sleep(200)
    Send("{ENTER}")
EndFunc

Func Sendinformation4()
    Sleep(200)
    Send('{ENTER}')
    Sleep(200)
    Send('/use Eternal Earth')
    Sleep(200)
    Send("{ENTER}")
EndFunc

Func TogglePause()
    $Paused = NOT $Paused
    While $Paused
        sleep(100)
        ToolTip('Script is "Paused"',0,0)
    WEnd
    ToolTip("")
EndFunc

Now, I first tried using the whole "$time += 1" "Until $times = $hOre" or something like that. And that was giving me a hassle since I did not know exactly how to operate it and what was going on in that operation, so i decided tos witch it over to a while loop with a "If, Then" statement. now the problems are in "sendinformation(), and sendinformation2()" They just loop repeatedly forever until I am forced to right click my script and end it.

Also the second function is typing out '/use 0' instead of '/use [Combo Box choice]' Which is what I want. And one other thing I want to point out is towards the end of my main script i have a "$hOre = GUICtrlRead($Input3)/5" Which is supposed to take the number in $input3 and divide it by 5, then that number is used in the first Function. Please give me a hand.

Link to comment
Share on other sites

Excuse me for not taking longer to understand your full script, but for the loops you might want to consider an alternative such as:

For $x = 1 to $hOre
;execute code
Next

or

$timesdone = 0

Do
;execute code
$timesdone = $timesdone + 1
Until $timesdone = $hOre

Good luck.

Edited by nf67
Link to comment
Share on other sites

Yeah that's fine, but i went over that in the description at the bottom of my post, i first attempted that but i had no idea how to use it or how it worked, if you could help me out by describing exactly what it is doing and what each variable means than I will be more than happy to try it again :)

Link to comment
Share on other sites

It's not obvious what it is you don't understand. In your SendInformation2 function you have

If $times2 = $Input2 Then ExitLoop

but presumably you meant to have

If $times2 = GuiCtrlRead($Input2) Then ExitLoop

so if that is the problem it's just a question of checking your own code.

For/Next and other loops are desribed in the help as well as anyone will describe them in a post so you just need to play with them to understand them.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

Sure.

Yeah you need to use GuiCtrlRead to get the data out of an input box.

Func sendinformation2()
For $times2 = 1 To GuiCtrlRead($Input2)
    Sleep(200)
    Send('{ENTER}')
    Sleep(200)
    Send('/cast disenchant')
    Sleep(200)
    Send('{ENTER}')
    Sleep(100)
    Send('{ENTER}')
    Sleep(200)
    Send('/use ' & GUICtrlRead($Combo))
    Sleep(200)
    Send('{ENTER}')
    Sleep(3500)
Next
EndFunc

I would probably also have something in there to check if the input box contained a number > 0 and was actually numeric.

Oh yeah and just in case uh... NotePad lags you can maybe ping uh... Google occasionally and add the delay in the ping to each sleep. Maybe call the ping in an adlib or some junk so it keeps updating your sleeps so that if something lags out it won't throw off the script.

Edited by jebus495
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...