Jump to content

Need help with select item in IE dropdown list


Recommended Posts

in the web page http://software.intel.com/en-us/articles/vcsource-samples-optimizing-opencl/

There is a" Select sample" dropdown list . At first I thought I might be able to use " _IEFormElementOptionselect" to select the item. After I checked the html source file, the "download-samples" option was not inside "form".

If I can not use _IEFormElementOptionselect to select the option, is there any other way I can use AutoIt to select the iterm from the IE dropdown list?

the html sorce code for "download-samples":

<div id="download-samples"><select> <option>Select sample...</option> <option value="http://software.intel.com/file/43405">Download this sample only</option> <option value="http://software.intel.com/file/43406">Download all OpenCL samples</option> </select> <a href="#" class="button sampledownload" title="Download">DOWNLOAD</a></div>

Edited by newcome
Link to comment
Share on other sites

#include <IE.au3>
$site = "http://software.intel.com/en-us/articles/vcsource-samples-optimizing-opencl/"
$oIE = _IECreate($site)
$oDownloadSamples = _IEGetObjById($oIE, "download-samples")
$oDownloadSamplesSelect = _IETagNameGetCollection($oDownloadSamples, "select", 0)
$oDownloadSamplesSelect.focus
_IEFormElementOptionSelect($oDownloadSamplesSelect, "Download all OpenCL samples", 1, "byText")

Forgot to explain...

Line 3 - Creates the IE window

Line 4 - Get reference to the "download-samples" DIV

Line 5 - Get the first instance of "select option" object (index number = 0) within "download-samples" DIV

Line 6 - Focus the drop-down (without this the option you want still gets selected but not visibly)

Line 7 - Select it

Edited by MrMitchell
Link to comment
Share on other sites

You're welcome but just remember there's no error checking so you risk script crash without it. Also, might want to replace the .focus with "_IEAction()" and use the "focus" action since it's already in the UDF. I don't use IE UDF a lot so I forget what's in there or somehow just miss these things in the help file.

Link to comment
Share on other sites

#include <IE.au3>

$site = "http://software.intel.com/en-us/articles/vcsource-samples-optimizing-opencl/"
$option = "Download all OpenCL samples"
Local $oIE = _IECreate($site)
Local $oDownloadSamples = _IEGetObjById($oIE,"download-samples")
Local $oDownloadSamplesSelect = _IETagNameGetCollection($oDownloadSamples, "select", 0)
_IEAction($oDownloadSamplesSelect, "focus")

For $sample in $oDownloadSamplesSelect
If $sample.innerText == $option Then
_IEFormElementOptionSelect($oDownloadSamplesSelect, $option, 1, "byText")
EndIf
Next
MrMitchell, you are so through and helpfule Thank you vvery much! You are right that there is a UDF _IEACtion() can be use with "focus"

Edited by newcome
Link to comment
Share on other sites

  • 4 years later...
On 7/20/2012 at 1:16 AM, MrMitchell said:

$oDownloadSamples = _IEGetObjById($oIE, "download-samples")

$oDownloadSamplesSelect = _IETagNameGetCollection($oDownloadSamples, "select", 0)

Can somebody please elaborate on this part?

AFAIK and on what ive done till now, suppose the source was like <select name = "something">, then the codes,

//////////////////////////////

$ref = _IETagNameGetCollection($oIE(basic reference object returned after creation), "select", 0)

For $i in $ref

  ConsoleWrit($i.name)

Next

///////////////////////////

This part will display "something" as we specifically referenced to select and then name descriptor within it.

But here select is just a tag without any inner descriptor or anything

So basically how does the Tagnamegetcollection function work??.....Please i am very new to autoit, any help would be really appreciated :)

 

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...