Sign in to follow this  
Followers 0
dinodod

Need help understanding _IEFormElementGetCollection please

4 posts in this topic

#1 ·  Posted (edited)

I am trying to create a logon script for the online game Simcountry (www.SimCountry.com). This script can be used on any number of other sites so i don't want to hear anyone screaming BOT MAKER please. I am not making a bot to play the game, just collect the data for processing information. I still manually play the game!

On the page: http://www.simcountry.com/cgi-bin/cgip?plo...Site=simcountry, there is the logon form that has no name assigned to it so I came across using _IEFormElementGetCollection to try to perform the function I need to logon for me yet I am confused over how it works.

The Google example is very simple but I haven't quite figured out how to adjust it to make it work for another site, in this case, SimCountry.

One such sample code I'm working on is as follows:

#include <IE.au3>
Dim $sMsg
$oIE = _IECreate ("http://www.simcountry.com/cgi-bin/cgip?plog&miSite=simcountry")
_IELoadWait ($oIE)

$oForm = _IEFormGetCollection ($oIE, 0)
$oQuery = _IEFormElementGetCollection ($oForm, 0)
;_IEFormElementSetValue ($oQuery, "AutoIt IE.au3")

$i = 0
For $oElem In $oQuery
    $sMsg &= $i & ":  " & _IEFormElementGetValue($oElem) & @CRLF
    $i += 1
Next
MsgBox(64, " Results", $sMsg)

Can anyone educate me please on how this works on another site?

thanks!

Edited by dinodod

Digital Chaos - Life as we know it today.I'm a Think Tank. Problem is, my tank is empty.The Quieter you are, the more you can HearWhich would you choose - Peace without Freedom or Freedom without Peace?Digital Chaos Macgyver ToolkitCompletely Dynamic MenuSQLIte controlsAD FunctionsEXCEL UDFPC / Software Inventory UDFPC / Software Inventory 2GaFrost's Admin Toolkit - My main competitor :)Virtual SystemsVMWAREMicrosoft Virtual PC 2007

Share this post


Link to post
Share on other sites



Download DebugBar if you don't have it yet. Most of the time you don't need to bother with forms unless this form element's name is used more than once so you don't need to play with indices.

#include <IE.au3>

Dim $o_IE = _IECreate('http://www.simcountry.com/cgi-bin/cgip?plog&miSite=simcountry')

Dim $oInput = _IEGetObjByName($o_IE, 'miEmailAddress')
$oInput.Value = 'user@mail.com'
$oInput = _IEGetObjByName($o_IE, 'miPassword')
$oInput.Value = '********'

$oInput = _IEGetObjByName($o_IE, 'Login')
$oInput.Click()

Share this post


Link to post
Share on other sites

All good advice.

I would, however, rewrite your example. Yours is fine if you're very comfortable with the DOM, but using the _IE fuctions will give you more feedback and error handling if you make a mistake (like trying to set the value of the wrong type of element):

#include <IE.au3>

$o_IE = _IECreate('http://www.simcountry.com/cgi-bin/cgip?plog&miSite=simcountry')

$oInput = _IEGetObjByName($o_IE, 'miEmailAddress')
_IEFormElementSetValue($oInput, 'user@mail.com')
$oInput = _IEGetObjByName($o_IE, 'miPassword')
_IEFormElementSetValue($oInput, '********')

$oInput = _IEGetObjByName($o_IE, 'Login')
_IEAction($oInput, 'click')

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

Share this post


Link to post
Share on other sites

Thank you both! Seems the solution was much simplier than I thought once I saw the samples you gave me. I just didn't understand how those functions worked.

-Karl


Digital Chaos - Life as we know it today.I'm a Think Tank. Problem is, my tank is empty.The Quieter you are, the more you can HearWhich would you choose - Peace without Freedom or Freedom without Peace?Digital Chaos Macgyver ToolkitCompletely Dynamic MenuSQLIte controlsAD FunctionsEXCEL UDFPC / Software Inventory UDFPC / Software Inventory 2GaFrost's Admin Toolkit - My main competitor :)Virtual SystemsVMWAREMicrosoft Virtual PC 2007

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
Sign in to follow this  
Followers 0