Jump to content

Using IE.au3 and _IEGetObjByname() and _IEFormElementSetValue()


darcaro
 Share

Recommended Posts

Hello - I am trying to use these functions to automatically login to a javascript website. With many other pages, the IE.au3 has worked perfectly, but for some reason, it is not working with this page. I think it has something to do with frames and tables but I do not know enough about it to get it to work. The actual page is pasted below, I am trying to populate txtUserID - if someone could point me in the right direction, that would be really great

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >

<HTML>

<HEAD>

<title>

ADP ezLaborManager - Login

</title>

<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">

<meta content="C#" name="CODE_LANGUAGE">

<meta content="Javascript" name="vs_defaultClientScript">

<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">

<LINK href="/ezLaborManagerNet/css/ADPezLaborManager.css?16" type="text/css" rel="stylesheet">

<LINK href="/ezLaborManagerNet/css/ADPezLaborManagerControlClasses.css?16" type="text/css" rel="stylesheet">

<link rel="shortcut icon" href="/ezLaborManagerNet/ADPFavicon.ico" />

<script language="javascript" src="/ezLaborManagerNet/js/commonpagefunctions.js?16_4"></script>

<script language="javascript" src="/ezLaborManagerNet/js/pagedirty.js?16_4"></script>

<script language="javascript" src="/ezLaborManagerNet/js/GlobalStrings_en-US.js?16_4"></script>

<meta name="ROBOTS" content="NOINDEX, NOFOLLOW">

<script language="javascript">

<!--

function doSubmit(evt, id)

{

evt = (evt) ? evt : ((event) ? event : null);

if(evt.keyCode == 13)

{

document.getElementById(id).focus();

document.getElementById(id).click();

}

}

function performonload()

{

document.forms[0].txtUserID.focus();

}

function CreateBookmarkLink()

{

var title = "";

var url = "";

if (window.sidebar)

{

// Mozilla Firefox Bookmark

window.sidebar.addPanel(title, "","");

}

else if( window.external )

{

// IE Favorite

window.external.AddFavorite( url, title);

}

}

//-->

</script>

</HEAD>

<body marginheight="0" marginwidth="0">

<form name="Login" method="post" action="Login.aspx?cID=65118&amp;lng=en-US" id="Login">

<input type="hidden" name="__PageDirty" value="False" />

<input type="hidden" name="__PageDirtyMsg" value="Changes have been made but not saved.\nYour changes will be lost if you continue.\n\nDo you wish to continue?" />

<input type="hidden" name="__EVENTTARGET" value="" />

<input type="hidden" name="__EVENTARGUMENT" value="" />

<input type="hidden" name="__VIEWSTATE" value="+xmSYyN9vqejHui7ZGUIQYcYnPXUwMwcxLXcXJ7C6v10WNR+7tCKJpk0Jm8UtM8/uGQhSDasxyEL/Ch1FuAz0dG+PABtLFXsi82yZ0VALsaAd2/M5i9HVvH6kuNBhQYlZEmjQ77mvK/nWP5N85nDUcoEd6oPBM8PY2qjoKSvIJpsZEZVNQ73hrmKOuqRYiD3rY/dtbVXRkoh8rJMkuDwetEg6aKGCiCviSJvE23yu7P9JM2g9eM9r01o+tixI9LpyyxtRrLqmlkABg/osylnr2w7LnUoc9vlzKYOpW4gfDK39vPG8NxYyTg8NXBbB9C2AxVY2JQux+hNyrIctEWtnK7wMt4eXRiESEd/mFXjCvRqEKKkmteX8MswlZ46OzGSf6UxNRlEj5sI7lS4R9nbVWnUllqwsaETxsQlcs2WXla51Ok6YxlAIoI2u8NK+K7vDYZEf1U0yo8KefgD15vPvBs7iMxY/BvWVLWoAbsAg1g4FuJ+zJOx2kyMsMxaAMKJImnf6ltuJfWjeqGBbNrLFg==" />

<script language="javascript" type="text/javascript">

<!--

function __doPostBack(eventTarget, eventArgument) {

var theform;

if (window.navigator.appName.toLowerCase().indexOf("microsoft") > -1) {

theform = document.Login;

}

else {

theform = document.forms["Login"];

}

theform.__EVENTTARGET.value = eventTarget.split("$").join(":");

theform.__EVENTARGUMENT.value = eventArgument;

theform.submit();

}

// -->

</script>

<script language="Javascript">

var objAboutWindow;

function OpenAboutWindow()

{

if(objAboutWindow)

objAboutwindow.close();

objAboutWindow = window.open('/ezLaborManagerNet/Misc/About.aspx?lng=en-US&cID=65118','ezLaborManagerOptions','width=550,height=575,resizable=1,status=1,scrollbars=1');

objAboutwindow.focus();

return void(0);

}

</Script>

<script language="Javascript">

var objInfoWindow;

function OpenInfoWindow(wndw)

{

if(wndw != 'p' && wndw != 'l')

return;

var windowName = '';

var windowLocation = '';

var windowParams = '';

if(wndw == 'p')

{

windowLocation = '/ezLaborManagerNet/Misc/Privacy.aspx?lng=en-US&cID=65118';

windowName = 'ADPPrivacy';

windowParams = 'width=650,height=700,resizable=1,status=1,scrollbars=1';

}

else

{

windowLocation = '/ezLaborManagerNet/Misc/Legal.aspx?lng=en-US&cID=65118';

windowName = 'ADPLegal';

windowParams = 'width=650,height=700,resizable=1,status=1,scrollbars=1';

}

if(objInfoWindow)

objInfowindow.close();

objInfoWindow = window.open(windowLocation, windowName, windowParams);

objInfowindow.focus();

return void(0);

}

</Script>

<script language="Javascript">

<!--

function OpenSuggestionWindow()

{

var winParam = "width=750,height=700,resizable=1,status=1,scrollbars=1";

var objWin = window.open("/ezLaborManagerNet/Misc/Suggestions.aspx?lng=en-US&cID=65118&fID=", "suggestion", winParam);

objWin.focus();

}

//-->

</script>

<table height="100%" cellSpacing="0" cellPadding="0" width="100%" border="0">

<tr>

<td vAlign="top" height="100%">

<table height="100%" cellSpacing="0" cellPadding="0" width="100%" border="0">

<tr>

<td height="90">

<table id="Table1" height="100%" cellSpacing="0" cellPadding="0" width="100%" border="0">

<tr>

<td class="Banner" width="100%">

<table id="Table2" cellSpacing="0" cellPadding="0" width="100%" border="0">

<tr>

<td vAlign="middle">

<a target="_blank"

href="http://www.adp.com">

<img id="LogoBanner1_imgClientLogo" key="ADPLogo.jpg" src="/ezLaborManagerNet/images/en-US/ADPLogo.jpg" alt="" border="0" />

</a>

</a>

</td>

<td><IMG height="1" src="/ezLaborManagerNet/images/spacer.gif" width="50"></td>

<td vAlign="middle" width="100%">

<table id="Table3" cellSpacing="0" cellPadding="0" width="100%" border="0">

<tr>

<td class="CompanyName2" vAlign="top" noWrap><span id="LogoBanner1_lblCompanyName">FSKS</span></td>

</tr>

<tr>

<td vAlign="top" width="100" bgColor="red">

<IMG height="1" src="/ezLaborManagerNet/images/spacer.gif" width="1"></td>

</tr>

<tr>

<td class="WelcomeText">&nbsp;<span class="NameText"><span id="LogoBanner1_lblName"></span></span></td>

</tr>

</table>

</td>

</tr>

</table>

</td>

</tr>

<tr>

<td bgcolor="black" height="1"><IMG height="1" src="/ezLaborManagerNet/images/spacer.gif" width="1"></td>

</tr>

<tr>

<td align="right"><img id="LogoBanner1_imgProductLogo" key="ezLMLogoWhite.gif" src="/ezLaborManagerNet/images/en-US/ezLMLogoWhite.gif" alt="" border="0" /></td>

</tr>

<tr id="br2">

<td>

<table cellSpacing="0" cellPadding="0" width="100%" border="0">

<tr>

<td><span id="LogoBanner1_tabControl"></span></td>

</tr>

</table>

</td>

</tr>

</table>

<script language="javascript" type="text/javascript">

aryRestrictedTables[aryRestrictedTables.length] = ["Table1", 0];

var strHelpPageMode = "";

</script>

</td>

</tr>

<tr>

<td vAlign="top" align="center" height="100%">

<table cellSpacing="0" cellPadding="0" width="95%" border="0">

<tr>

<td style="PADDING-TOP: 1px" vAlign="top" width="40%">

<table cellSpacing="0" cellPadding="2" width="100%" border="0">

<tr>

<td colSpan="2">

<!-- Section Header Start -->

<table class="SectionHeader" cellSpacing="0" cellPadding="0" border="0">

<tr>

<td class="SectionHeader-LeftCell"><span id="lblLogin" key="lbl_Login">Login</span></td>

</tr>

</table>

</td>

</tr>

<TR>

<TD colSpan="2"></TD>

</TR>

<tr>

<td style="PADDING-RIGHT: 15px" vAlign="top">

<div class="ThinRedBox">

<table cellSpacing="0" cellPadding="2" width="100%" border="0">

<tr>

<td class="LanguageTitle" align="center"><span id="lblLanguage" key="lbl_Language">Language</span></td>

</tr>

<TR>

<TD noWrap><table cellspacing="0" cellpadding="2" border="0" style="border-width:0px;border-collapse:collapse;">

<tr>

<td nowrap="nowrap"><a class="AppLink" href="/ezLaborManagerNet/Login/Login.aspx?cID=65118&amp;lng=en-US">English (United States)</a></td>

</tr><tr>

<td nowrap="nowrap"><a class="AppLink" href="/ezLaborManagerNet/Login/Login.aspx?cID=65118&amp;lng=en-CA">English (Canada)</a></td>

</tr><tr>

<td nowrap="nowrap"><a class="AppLink" href="/ezLaborManagerNet/Login/Login.aspx?cID=65118&amp;lng=fr-CA">français (Canada)</a></td>

</tr><tr>

<td nowrap="nowrap"><a class="AppLink" href="/ezLaborManagerNet/Login/Login.aspx?cID=65118&amp;lng=en-GB">English (United Kingdom)</a></td>

</tr>

</table></TD>

</TR>

</table>

</div>

</td>

<td width="100%">

<table cellSpacing="0" cellPadding="0" border="0">

<tr>

<td noWrap width="15%"><span id="lblClient" class="BoldLabel" key="lbl_ClientName">Client Name</span></td>

<td noWrap width="85%">&nbsp;&nbsp;

<a id="btnChangeClient" key="hyp_ChangeClient" onclick="event.cancelBubble=true;" href="javascript:__doPostBack('btnChangeClient','')">Change Client</a></td>

</tr>

<tr>

<td colSpan="2"><span id="lblClientName" class="ClientNameLabel">FSKS</span></td>

</tr>

<tr>

<td colSpan="2">&nbsp;</td>

</tr>

<tr>

<td style="PADDING-BOTTOM: 4px" colSpan="2"><span id="lblUserID" class="BoldLabel" key="lbl_UserID">User ID</span></td>

</tr>

<tr>

<td style="PADDING-BOTTOM: 4px" colSpan="2"><input name="txtUserID" type="text" maxlength="25" id="txtUserID" autocomplete="false" onkeydown="doSubmit(event,'btnLogin_active');" /></td>

</tr>

<tr>

<td style="PADDING-BOTTOM: 4px" colSpan="2"><span id="lblPassword" class="BoldLabel" key="lbl_Password">Password</span></td>

</tr>

<tr>

<td colSpan="2"><input name="txtPassword" type="password" maxlength="25" id="txtPassword" onkeydown="doSubmit(event,'btnLogin_active');" /></td>

</tr>

<TR>

<TD colSpan="2">&nbsp;</TD>

</TR>

<TR>

<TD colSpan="2"><span id="btnLogin_disabled" class="disabledButton" style="display:none;"><span class="btnLtDis">&nbsp;</span><span class="btnMdDis">Login</span><span class="btnRtDis">&nbsp;</span></span><a id="btnLogin_active" href="javascript:__doPostBack('btnLogin','')" onclick="disableButton('btnLogin', true);" class="btnLink" style="display:inline;"><span class="btnLtAct">&nbsp;</span><span class="btnMdAct">Login</span><span class="btnRtAct">&nbsp;</span></a><span id="btnLogin" key="btn_Login"></span></TD>

</TR>

</table>

</td>

</tr>

<TR>

<TD align="center" colSpan="2">&nbsp;</TD>

</TR>

</table>

</td>

<td>&nbsp;</td>

<td vAlign="top" width="60%">

<table cellspacing="2" width="100%">

<tr>

<td>

<!-- Section Header Start -->

<table class="SectionHeader" cellSpacing="0" cellPadding="0" border="0">

<tr>

<td class="SectionHeader-LeftCell">

<span id="PortalMessageControl1_lblMessages" key="lbl_Messages">Messages</span></td>

<td class="SectionHeader-RightCell">&nbsp;</td>

</tr>

</table>

</td>

</tr>

<tr>

<td>

<div class="InfoText">No messages</div>

</td>

</tr>

</table>

</td>

</tr>

</table>

</td>

</tr>

</table>

</td>

</tr>

<tr>

<td height="25">

<table id="Table22" height="36" cellSpacing="0" cellPadding="0" width="100%" border="0">

<tr class="Footer-AppInfoRow" height="16">

<td align="center" nowrap colspan="2">10/26/2009 08:49:18 AM&nbsp;v11.016.005.04 - xb&lt;;9g:9e,[[{' ezlmportal4.adp.com - undefined DPID - sA&lt;yuCnwIA]</td>

</tr>

<tr height="20">

<td class="FooterText" noWrap width="99%">Copyright ©2000-2009 Automatic Data Processing, Inc. All Rights Reserved.&nbsp;</td>

<td class="FooterBgColor" noWrap width="1%">

<span>

<a id="FooterControl1_hypAboutArrow" onclick="event.cancelBubble=true;" href="javascript:OpenAboutWindow();"><img src="/ezLaborManagerNet/images/footer_arrow.gif" alt="" border="0" /></a>&nbsp;<a id="FooterControl1_hypAbout" class="FooterLink" key="hyp_About" onclick="event.cancelBubble=true;" href="javascript:OpenAboutWindow();">ABOUT</a>&nbsp;&nbsp;&nbsp;</span>

<span>

<a id="FooterControl1_hypPrivacyArrow" onclick="event.cancelBubble=true;" href="javascript:OpenInfoWindow('p');"><img src="/ezLaborManagerNet/images/footer_arrow.gif" alt="" border="0" /></a>&nbsp;<a id="FooterControl1_hypPrivacy" class="FooterLink" key="hyp_Privacy" onclick="event.cancelBubble=true;" href="javascript:OpenInfoWindow('p');">PRIVACY</a>&nbsp;&nbsp;&nbsp;</span>

<span>

<a id="FooterControl1_hypLegalArrow" onclick="event.cancelBubble=true;" href="javascript:OpenInfoWindow('l');"><img src="/ezLaborManagerNet/images/footer_arrow.gif" alt="" border="0" /></a>&nbsp;<a id="FooterControl1_hypLegal" class="FooterLink" key="hyp_Legal" onclick="event.cancelBubble=true;" href="javascript:OpenInfoWindow('l');">LEGAL</a>&nbsp;&nbsp;</span>

</td>

</tr>

</table>

</td>

</tr>

</table>

</form>

</FORM>

<script language="javascript" type="text/javascript">

performonload();

</script>

</body>

</HTML>

Link to comment
Share on other sites

There is some complex Javascript at play here. There are scripts missing from your snapshot above however:

<INPUT onkeydown="doSubmit(event,'btnLogin_active');" id=txtUserID maxLength=25 name=txtUserID autocomplete="false">

function doSubmit(evt, id)
{
evt = (evt) ? evt : ((event) ? event : null);
if(evt.keyCode == 13)
{
document.getElementById(id).focus();
document.getElementById(id).click();
}
}

There are scripts missing from your snapshot above however:

<script language="javascript" src="/ezLaborManagerNet/js/commonpagefunctions.js?16_4"></script>
<script language="javascript" src="/ezLaborManagerNet/js/pagedirty.js?16_4"></script>
<script language="javascript" src="/ezLaborManagerNet/js/GlobalStrings_en-US.js?16_4"></script>

that make it behave differently, because this works with your code locally:

#include <IE.au3>

$oIE = _IEAttach("ADP")
$oUserId = _IEGetObjById($oIE, "txtUserID")
_IEFormElementSetValue($oUserId, "test")

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

That is great Dale, thanks so much for your input - are you saying that I may not be able to automate logging into this page? I'm not sure if it helps, but there is a preliminary page that launches prior to this one, where the user has to click a url - that one i can get past with _ielinkclickbytext

Link to comment
Share on other sites

It is almost always possible... but you may need to dig through it all to figure out what must be done.

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

Without sounding like too much of a pain (or too much of a moron!) .....could you give me an idea of where you would start? I'm really new to this, so digging through it would be nearly impossible for me. thanks for all your help!

Link to comment
Share on other sites

I'm sorry. Then this is not the project for you to start on. You'll need someone locally who is experienced with Javascript to assist/teach you or get a book and pick some easier projects to build up your chops first.

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

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