Jump to content

Recommended Posts

Posted

Ok I'm making a script that logs into an online notepad and saves data but when I get to the form that allows you to write the note it has two forms with the same name.

well actually neither have a name which I've learned means to use '0'

$oIE = _IECreate('http://www.jotthisdown.com/index.php')
If StringInStr(StringTrimRight(_IEBodyReadText($oIE), StringInStr(_IEBodyReadText($oIE), @CRLF, 0, -1)), 'Welcome Back') = 0 Then ; checks to see if you are already logged in
     $oForm = _IEFormGetObjByName($oIE, 'loginform')
     $oUser = _IEFormElementGetObjByName($oForm, 'username')
     $oPassword = _IEFormElementGetObjByName($oForm, 'password')
     $oSubmit = _IEFormElementGetObjByName($oForm, 'Submit')
     _IEFormElementSetValue($oUser, $iUser)
     _IEFormElementSetValue($oPassword, $iPassword)
     _IEAction($oSubmit, 'click')
 EndIf

$oForm = _IEFormGetObjByName($oIE, '0')
$oNotes = _IEFormElementGetObjByName($oForm, 'notes')
$oSubmit = _IEFormElementGetObjByName($oForm, 'Submit1')
_IEFormElementSetValue($oNotes, 'Test')
Posted

No name doesn't mean use 0...

This is what you want:

_IEFormGetCollection

--------------------------------------------------------------------------------

Returns a collection object variable representing the Forms in the document or a single form by index.

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

Posted

When you do what?

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

Posted (edited)

$oForms = _IEFormGetCollection ($oIE)
MsgBox(0, "Forms Info", "There are " & @extended & " forms on this page")
For $oForm In $oForms
    MsgBox(0, "Form Info", $oForm.name)
Next

Taken from _IEFormGetCollection help file

Edit:

I just made a Username: Demo, Password: Demo account in case it would help to see the form I'm using

Edited by AcidCorps
Posted

Pass an index parameter to _IEFormGetCollection to reference a specific form.

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

Posted (edited)

Snip from help file:

#include <IE.au3> 
_IEFormGetCollection ( ByRef $o_object [, $i_index = -1] )
...
$i_index Optional: specifies whether to return a collection or indexed instance
0 or positive integer returns an indexed instance
-1 = (Default) returns a collection

So if you want form number two, then use:

_IEFormGetColection ($oIE, 1)

Edited by Brickoneer
Posted

Also from the help file...

; *******************************************************
; Example 1 - Get a reference to a specific form by 0-based index,
;               in this case the first form on the page
; *******************************************************
;
#include <IE.au3>
$oIE = _IECreate ("http://www.google.com")
$oForm = _IEFormGetCollection ($oIE, 0)
$oQuery = _IEFormElementGetCollection ($oForm, 1)
_IEFormElementSetValue ($oQuery, "AutoIt IE.au3")
_IEFormSubmit ($oForm)
Posted (edited)

give me an example of that? seen it down but can't remember where.

Try...

$oForm = _IEFormGetCollection ($oIE)
$oForm2 = _IEFormGetCollection ($oIE,1)
Edited by Klexen

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
×
×
  • Create New...