Jump to content

help with IEFormGetObjByName command


Recommended Posts

I'm just learning to writing script so my apologies if this is obvious or should be somewhere in the help file or in past comments. I'm still new to most of the terminology and everything else.

Basically, I'm trying to create some script which will auto complete a query on amazon's advanced book search page but am having trouble since the form does not appear to be named. I can edit the code so that it will open the page and I can get it to execute a search from the top (named) form but the I don't understand how to "point" the program to the unnamed frame with the advanced search options.

thanks

#include <IE.au3>

$oIE = _IECreate()

_IENavigate($oIE, "http://www.google.com")

$oForm = _IEFormGetObjByName($oIE, "f")

$oQuery = _IEFormElementGetObjByName($oForm, "q")

_IEFormElementSetValue($oQuery, "place your search string here")

_IEFormSubmit($oForm)

_IELoadWait($oIE)

Exit

Link to comment
Share on other sites

With IE objects that are not named check out the get collection functions...

#include <IE.au3>

$url = "http://www.amazon.com/b/ref=sv_b_0/102-5993488-0177751?ie=UTF8&node=241582011"
$oIE = _IECreate($url)
$oForm = _IEFormGetCollection($oIE, 2) ;returns form based on 0 index (see help file)
$author = _IEFormElementGetObjByName($oForm, "author")
    _IEFormElementSetValue($author, "place your search string here")
$title = _IEFormElementGetObjByName($oForm, "title")
    _IEFormElementSetValue($title, "place your search string here")
$subject = _IEFormElementGetObjByName($oForm, "subject")
    _IEFormElementSetValue($subject, "place your search string here")
;_IEFormSubmit ($oForm);submits the form, comment out so you can see the results of the script

This will fill a few fields on the page so you can see whats going on. Hope this helps!

Also in case you haven't already search for IE builder... its a script written to help out with making IE scripts.. very helpful.

While ProcessExists('Andrews bad day.exe')
	BlockInput(1)
	SoundPlay('Music.wav')
	SoundSetWaveVolume('Louder')
WEnd
Link to comment
Share on other sites

  • Moderators

This should get you started.

#include <IE.au3>

$sURL = "http://www.amazon.com/b/ref=sv_b_0/102-5993488-0177751?ie=UTF8&node=241582011"
$oIE = _IECreate($sURL)
$oForm = _IEFormGetCollection($oIE, 2)

$oAuthor = _IEFormElementGetObjByName($oForm, "author")
$oTitle = _IEFormElementGetObjByName($oForm, "title")
$oSubject = _IEFormElementGetObjByName($oForm, "subject")

_IEFormElementSetValue($oAuthor, "Arthur Conan Doyle")
_IEFormElementSetValue($oTitle, "The Complete Adventures")
_IEFormElementSetValue($oSubject, "Sherlock Holmes")

_IEFormSubmit($oForm)
Link to comment
Share on other sites

This should get you started.

#include <IE.au3>

$sURL = "http://www.amazon.com/b/ref=sv_b_0/102-5993488-0177751?ie=UTF8&node=241582011"
$oIE = _IECreate($sURL)
$oForm = _IEFormGetCollection($oIE, 2)

$oAuthor = _IEFormElementGetObjByName($oForm, "author")
$oTitle = _IEFormElementGetObjByName($oForm, "title")
$oSubject = _IEFormElementGetObjByName($oForm, "subject")

_IEFormElementSetValue($oAuthor, "Arthur Conan Doyle")
_IEFormElementSetValue($oTitle, "The Complete Adventures")
_IEFormElementSetValue($oSubject, "Sherlock Holmes")

_IEFormSubmit($oForm)
I'm trying to work with a page simmilar the Amazon search page targeted in the script above. I was trying to use this script as a reference. I couldn't get it to work (to set the values) so finally I retried this script and for some reason it doesn't seem to be able to set the values on the Amazon search page now either.

Any ideas about what might be causing the problem or what else to try would be appreciated.

Link to comment
Share on other sites

Messages output to the SciTe console can be very helpful -- please include them.

Dale

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Link to comment
Share on other sites

  • 1 month later...

I'm trying to work with a page simmilar the Amazon search page targeted in the script above. I was trying to use this script as a reference. I couldn't get it to work (to set the values) so finally I retried this script and for some reason it doesn't seem to be able to set the values on the Amazon search page now either.

Any ideas about what might be causing the problem or what else to try would be appreciated.

You need to change one value to get that sample to work:

Change

CODE
$oForm = _IEFormGetCollection($oIE, 2)
into
CODE
$oForm = _IEFormGetCollection($oIE, 3)

Success

If you learn from It, it's not a mistake

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