llkchris

How to select option without using form element?

4 posts in this topic

Hi all, this forum is great and I learned a lot about autoit through this forum. However, I am not able to find an answer to my problem here. I would like to auto-select a date of a drop down list. The html code is attached below, which is not under any form, as I could not find any form id before this div. 

<DIV id=datePanel __listener='<DIV id=datePanel><SELECT tabIndex=0 class=gwt-ListBox __eventBits="1024"><OPTION value="">- Please Select Date -</OPTION><OPTION value=20150919>19-09-2015 (Sat)</OPTION><OPTION value=20150920>20-09-2015 (Sun)</OPTION><OPTION value=20150921>21-09-2015 (Mon)</OPTION><OPTION value=20150922>22-09-2015 (Tue)</OPTION><OPTION value=20150923>23-09-2015 (Wed)</OPTION><OPTION value=20150924>24-09-2015 (Thu)</OPTION><OPTION value=20150925>25-09-2015 (Fri)</OPTION><OPTION value=20150926>26-09-2015 (Sat)</OPTION><OPTION value=20150927>27-09-2015 (Sun)</OPTION><OPTION selected value=20150928>28-09-2015 (Mon)</OPTION></SELECT></DIV>'>

<SELECT tabIndex=0 class=gwt-ListBox __eventBits="1024"><OPTION value="">- Please Select Date -</OPTION><OPTION value=20150919>19-09-2015 (Sat)</OPTION><OPTION value=20150920>20-09-2015 (Sun)</OPTION><OPTION value=20150921>21-09-2015 (Mon)</OPTION><OPTION value=20150922>22-09-2015 (Tue)</OPTION><OPTION value=20150923>23-09-2015 (Wed)</OPTION><OPTION value=20150924>24-09-2015 (Thu)</OPTION><OPTION value=20150925>25-09-2015 (Fri)</OPTION><OPTION value=20150926>26-09-2015 (Sat)</OPTION><OPTION value=20150927>27-09-2015 (Sun)</OPTION><OPTION selected value=20150928>28-09-2015 (Mon)</OPTION></SELECT></DIV>

I tried to use 

$oIE = _IECreate(http://www.example.com)
$oFrame = _IEframegetobjbyname($oIE,"main")
$datepanel = _IEGetObjByName($oFrame, "datepanel")
_IEFormElementOptionSelect($datepanel, "28-09-2015 (Mon)", 1, "byText")

I got an error "--> IE.au3 T3.0-2 Error from function _IEFormElementOptionSelect, $_IESTATUS_InvalidObjectType" 

I tried to use _IEpropertyset($datepanel, 'innertext', "28-09-2015 (Mon)"), which successfully changed the whole dropdownlist into text, but its not recognizable by the webpage. How can I select the option without a form element?

Thanks guys. 

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Not really versed in reading IE elements but maybe for testing and to figure out exactly what you need to set it to on PropertySet, manually set it to the date you need it to be and then do some form of ControlRead to see what the output is? Just throwing ideas until someone more versed in IE controls comes along.

 

Good luck!

 

*** EDIT ***

 

Little edit here

 

But I'm not quite sure what you could be doing wrong because just grabbing a quick example from the HelpFile and then finding a random drop down menu online I was able to change the value accordingly using

 

#include <IE.au3>

$oIE = _IECreate("http://www.echoecho.com/htmlforms11.htm")
$datepanel = _IEGetObjByName($oIE, "dropdownmenu")
_IEFormElementOptionSelect($datepanel, "Cheese", 1, "byText")


While 1
    Sleep(10)
WEnd

 

Edited by Damein

MCR.jpg?t=1286371579

Most recent sig. I made

Quick Launcher W/ Profiles Topic Movie Database Topic & Website | LiveStreamer Pro Website | YouTube Stand-Alone Playlist Manager: Topic | Weather Desktop Widget: Topic | Flash Memory Game: Topic | Volume Control With Mouse / iTunes Hotkeys: Topic | Weather program: Topic | Paws & Tales radio drama podcast mini-player: Topic | Quick Math Calculations: Topic

Share this post


Link to post
Share on other sites

I guess its because my datepanel is not a form element? but in your example, the drop down list is within a form. And that's why the function <_IEFormEleentOptionSelect} works?

:(

 

aww

Share this post


Link to post
Share on other sites

Possibly. Maybe if you need to you could just use a macro? Pressing the {TAB} key according to how many times you need to on the webpage to select the dropdown box, then pressing the {DOWN} key until the item is selected.

 

Something like this:

 

#include <IE.au3>


Global $TabCount = 28, $oIE, $Gui, $Web

$oIE = _IECreateEmbedded()

$Gui = GuiCreate("IE Window", 600, 600)

$Web = GUICtrlCreateObj($oIE, 10, 10, 580, 580)

GuiSetState()


_IENavigate($oIE, "http://www.echoecho.com/htmlforms11.htm")


For $i = 1 To $TabCount
    Send("{TAB}")
    Sleep(100)
Next

Sleep(200)
Send("{DOWN}")

While 1
    Sleep(10)
WEnd

 

Although this isn't 100% because I don't know how to give the IE control focus off the top of my head and I'm not at home, so the tabs won't send. But if you can figure that part out this should work.

 

Good luck!


MCR.jpg?t=1286371579

Most recent sig. I made

Quick Launcher W/ Profiles Topic Movie Database Topic & Website | LiveStreamer Pro Website | YouTube Stand-Alone Playlist Manager: Topic | Weather Desktop Widget: Topic | Flash Memory Game: Topic | Volume Control With Mouse / iTunes Hotkeys: Topic | Weather program: Topic | Paws & Tales radio drama podcast mini-player: Topic | Quick Math Calculations: Topic

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