Jump to content

picking from a dropdown


Recommended Posts

I am writing a gamebot for dark throne and am having trouble in selecting a drop down menu . The name of it is "type" but it defaults to miners which is value 2 i want berzerkers which is value 9 but nothing i try seems to work i am pretty new to autoit but have come a long way and writen a working bot only this issue now evades me can anyone steer me in the right direction.

below is the source of the webpage

class="box_header" align="center">Select a Type to Assassinate</td> </tr> <tr> <td class="box_content" align="center"> <select name="type"> <option value="2">Miners</option> <option value="3">Soldiers</option> <option value="4">Guards</option> <option value="5">Spies</option> <option value="6">Sentries</option> <option value="7">Knights</option> <option value="8">Archers</option> <option value="9">Berserkers</option> <option value="10">Elite Archers</option> </select> </td> </tr></table></div><input class="submitImg" type="image" src="http://omega2.darkthrone.com/templates/blue/images/buttons/assassinate.gif"></form>

this is my code so far the part that does not work is from $o_zerks downwards

$o_form = _IEFormGetCollection($oIE, "") ; colect form

$o_FIND = _IEGetObjByName($o_form, "numSpies") ; input 10 spies to ass with

_IEFormElementSetValue($o_FIND, "10")

$o_zerks = _IEFormElementGetObjByName($o_form, "type") ; name of dropdown

$oQuery = _IEFormElementGetObjByName ($o_Form, "9") ; set value to 9 to ass berzerkers

_IEFormElementSetValue ($oQuery, "9")

_IEFormSubmit ($o_Form, 0) ; submit form

sleep(6000)

_IEFormImageClick($oIE, "assassinate.gif", "src")

if anyone can guide it would be apriciated

Edited by An_icehole
Link to comment
Share on other sites

1º - Download DebugBar: www.debugbar.com

2º - Look at this example I made and see if it can be on any help:

#include <IE.au3>
Dim $Selected[5]
;Create the explorer
$oIE =_IECreate("http://losprofes.110mb.com/test/page.html")


;Get the form
$oForm = _IEFormGetObjByName ($oIE, "myform")
;Get the dropdown
$oSelect = _IEFormElementGetObjByName ($oForm, "mydropdown")
;Select 2nd item in dropdown.
_IEFormElementOptionselect ($oSelect, 1, 1, "byIndex")
;Get the value of the selected item
$Selected[0]= _IEFormElementGetValue($oSelect)
;Show you the value
MsgBox(0,"","Selected: "&$Selected[0])
;Go to the next page
_IELinkClickByText($oIE ,"Go to page 2")
;Wait.
_IELoadWait($oIE)


;Get the form
$oForm = _IEFormGetObjByName ($oIE, "myform")
;Get the dropdown
$oSelect = _IEFormElementGetObjByName ($oForm, "mydropdown")
;Select 1st item of the dropdown
_IEFormElementOptionselect ($oSelect, 0, 1, "byIndex")
;Get value of the selected item
$Selected[1]= _IEFormElementGetValue($oSelect)
;Show you the value
MsgBox(0,"","Selected: "&$Selected[1])
;Go to the next page
_IELinkClickByText($oIE ,"Go to page 3")
;Wait.
_IELoadWait($oIE)


;Get the form
$oForm = _IEFormGetObjByName ($oIE, "myform")
;Get the dropdown
$oSelect = _IEFormElementGetObjByName ($oForm, "mydropdown")

;Loop to check if the item that will be selected now has already been taken
For $i=0 To UBound($Selected)
    ;Will select an option in the dropdown every loop
    _IEFormElementOptionselect ($oSelect, $i, 1, "byIndex")
    ;Will exit once the array $Selected is empty
    If $Selected[$i]="" Then ExitLoop
    ;Will get the value of the selected option in the previous step
    $Check=_IEFormElementGetValue($oSelect)
    ;Loop to check if the value of the selected option matches one in the array
    For $a=0 To UBound($Selected)
        If $Check=$Selected[$a] Then
            MsgBox(0,"","The item "&$Check&" has been previously selected. Picking next one.")
            ExitLoop
        EndIf
    Next
Next

MsgBox(0,"","The selected item is: "&_IEFormElementGetValue($oSelect)&". This item has not been selected before.")
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...