mpcluever

Clicking Javascript button in IE

8 posts in this topic

#1 ·  Posted (edited)

I'm having trouble getting my script to click a javascript button in IE. I've identified the button in the source code.

<TD style="display:none" id="tdBtnAccount" width="16%" bgcolor="white">

<DIV id="div1" width="100%" class="lmNormal"><A class="lmNormal" id="button1" href="Javascript:Navigate('button1','/access/account.aspx','div1')">Account</A></DIV>

</TD>

What's the best way to click this? Any push in the right direction would be greatly appreciated!

Edited by mpcluever

Share this post


Link to post
Share on other sites



Looks like a standard _IEAction() / _IEGetObjById() combo... does that not work or have you tried it yet?

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

--> IE.au3 V2.4-0 Warning from function _IEGetObjById, $_IEStatus_NoMatch (tdBtnAccount)

--> IE.au3 V2.4-0 Warning from function _IEGetObjById, $_IEStatus_NoMatch (div1)

--> IE.au3 V2.4-0 Warning from function _IEGetObjById, $_IEStatus_NoMatch (button1)

--> IE.au3 V2.4-0 Warning from function _IEGetObjById, $_IEStatus_NoMatch (Javascript:Navigate('button1','/access/account.aspx','div1'))

It's not matching anything by ID or Name. Could this be the cause of my problem?

<script language='Javascript'>document.getElementById('tdBtnHome').style.display = 'block';document.getElementById('tdBtnAccount').style.display = 'block';document.getElementById
('tdBtnOrderMenu').style.display = 'block';document.getElementById('tdBtnCart').style.display = 'block';document.getElementById('tdBtnCheckOut').style.display = 'block';</SCRIPT></TD>

My Code:

$oIE = _IECreate("http://www.amphire.com/access/custompages/rsi/logon.aspx")
$oForm = _IEFormGetObjByName($oIE, "formLogon")
$oText = _IEFormElementGetObjByName($oForm, "vsLogonName")
_IEFormElementSetValue($oText, $RSI_Username)
$oPassword = _IEFormElementGetObjByName($oForm, "vsPassword")
_IEFormElementSetValue($oPassword, $RSI_Password)
_IEFormSubmit($oForm)
_IELinkClickByText($oIE, "Distributor Ordering")
$AccountButton = _IEGetObjById($oIE, "Javascript:Navigate('button1','/access/account.aspx','div1')")
_IEAction($AccountButton, "click")

Page Source:

<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.0 Transitional//EN'><HTML>
<HEAD>
    <TITLE>Access</TITLE>
<META HTTP-EQUIV='PRAGMA' CONTENT='NO-CACHE'><META NAME='MS.LOCALE' CONTENT='en-us' /></HEAD>
<script language='Javascript' src='/access/script/formValidation.js'></SCRIPT>
<script language='Javascript' src='/access/script/listFunctions.js'></SCRIPT>
<script language='Javascript' src='/access/script/global.js'></SCRIPT>
<script language='Javascript' src='/access/script/xmldom.js'></SCRIPT>
<script language='Javascript' src='/access/script/modxml.js'></SCRIPT>
<LINK REL=stylesheet href='/assets/style/global.css' type=text/css>
<LINK REL=stylesheet href='/assets/style/RH.css' type=text/css><BODY onload="if(parent.frames.length==0) parent.location='welcome.aspx';">
<IFRAME id="budgetIframe" name="budgetIframe" style="DISPLAY: none; Z-INDEX: 1; LEFT: 350px; WIDTH: 405px; POSITION: absolute; TOP: 150px;HEIGHT:85px" marginheight="0" marginwidth="0" noresize frameborder="yes" scrolling="no" src=/access/blank.aspx?sessionKey=m7OeajwJY422s46HZZMEzl8jRJoMvPtmiXmYMavkHJc60T98rbHhTdBlv%2bcx4cgv7TEnaExyqBLrFWhGBtRuASDM7H1r290LEtRVMjRMmjQjuBoB65qxJ45NGTzUbsvk7BWy8xwQujtyJ%2f5o%2bKsbHpVqxWg8pJx9sBDtra9TmbUVTV3eXribGAv2WjlMpfwd></IFRAME>
 
<FORM name="formMenu" action="/access/frmBrowse.aspx?sessionKey=m7OeajwJY422s46HZZMEzl8jRJoMvPtmiXmYMavkHJc60T98rbHhTdBlv%2bcx4cgv7TEnaExyqBLrFWhGBtRuASDM7H1r290LEtRVMjRMmjQjuBoB65qxJ45NGTzUbsvk7BWy8xwQujtyJ%2f5o%2bKsbHpVqxWg8pJx9sBDtra9TmbUVTV3eXribGAv2WjlMpfwd" method="get" target="frmMain" onsubmit="goSearch(); return false;">
    <TABLE cellspacing="0" cellpadding="0" border="0" width="100%" height="100%">
        <TR>
            <TD width="100%" colspan="3">
<TABLE cellpadding="0" cellspacing="1" width="100%" class="siteBG">
    <TR align="middle" class="siteBG">
        <TD style="display:none" id="tdBtnHome" width="16%" bgcolor="white"><DIV  id='div0' width='100%' class='lmClick'><A class=lmClick id=button0 href='javascript:GoRsi();'>Home</A></DIV></TD></TD>
        <TD style="display:none" id="tdBtnAccount" width="16%" bgcolor="white">
            <DIV id="div1" width="100%" class="lmNormal"><A class="lmNormal" id="button1" href="Javascript:Navigate('button1','/access/account.aspx','div1')">Account</A></DIV>
        </TD>
        <TD style="display:none" id="tdBtnOrderMenu" width="16%" bgcolor="white">
            <DIV id="div2" width="100%" class="lmNormal"><A class="lmNormal" id="button2" href="Javascript:Navigate('button2','/access/ordermenu.aspx','div2')">Order</A></DIV>
        </TD>
        <TD style="display:none" id="tdBtnCart" width="16%" bgcolor="white">
            <DIV id="div3" width="100%" class="lmNormal"><A class="lmNormal" id="button3" href="Javascript:Navigate('button3','/access/cart.aspx', 'div3')">Cart</A></DIV>
        </TD>
        <TD style="display:none" id="tdBtnCheckOut" width="16%" bgcolor="white">
            <DIV id="div4" class="lmNormal"><A class="lmNormal" id="button4" href="Javascript:Navigate('button4','/access/checkout.aspx?cStage=Exception', 'div4')">Submit</A></DIV>
        </TD>
    </TR>
</TABLE>
<script language="Javascript"> 
 
var lNumButtons = 6;
 
function Navigate(sSelectButton, sURL, sSelectDiv)
{
    var oButton;
    var oDiv;
    var sLinkBack;
    var bNavigate = true;   
    
    //Added by S.D. 21/10/2008
    if(parent.frmTop.document.formMenu.bContinueSearch)
    {
        parent.frmTop.document.formMenu.bContinueSearch.value="0";
    }
    //Enable the search button incase the user started a search
    document.getElementById('SearchBtn').disabled = false;
    // See how we need to append the product history string 
    if(sURL.indexOf("checkout.aspx") > 0 || sURL.indexOf("?") > 0){
        if(!AddOnChargePrompt('popup1')) //Display prompt for AddOn charges
        {           
            return;
        }       
        sLinkBack = GetProductHistory(true);
    } else {
        if(sURL.indexOf("sessionKey") == -1) {
            if(sURL.indexOf("?") == -1) {
                sURL += "?" + getFrameworkParameters();
            } else {
                sURL += "&" + getFrameworkParameters();
            }
        }
        sLinkBack = GetProductHistory(false);
    }
    // Cycle through the nav buttons and set their class
    // to normal first, that way we don't need to figure
    // out which one is set to lmClick
    for(i=0;i<lNumButtons;i++) {
        var sButtonName = 'button' + i.toString();
        nav=document.getElementById(sButtonName);
        if(nav != null) {
            nav.className = 'lmNormal';
        }
    }
    // create select items
    oSelectButton = document.getElementById(sSelectButton)
    oSelectDiv = document.getElementById(sSelectDiv)
    // NOTE: The button (menuItem) will be re-enabled when the page displays
    if(sSelectButton == "button3") {
        // disable the button
        oSelectButton.enabled = false;
        // remove the href
        oSelectButton.href = '#';
        // set the style
        oSelectButton.className = 'lmClick';
    }
    // set selected styles
    if(oSelectButton)
        oSelectButton.className = "lmClick";
    if(oSelectDiv)
        oSelectDiv.className = "lmClick";
    // Build URL
    if(sURL.indexOf("?") == -1)
        sURL += sLinkBack;
    else
        sURL += "&" + sLinkBack.substring(1,sLinkBack.length-1);
    // Here we check if the cart has any modified items
    // if so then we trigger the UpdateCartQty() by unloading
    // the form to blank.asp which will post to the message frame
    // and redirect to the cart after updating the cart with
    // the items...
    if(parent.frames.frmTop.CartHasModifiedItems())
    {   
        // Set the navigate to URL, special case for MAC
        if(navigator.userAgent.indexOf("Mac") == -1)
        {
            var bParEdit = false;
            // From listFunctions.js (UpdateCartQty)
            if(parent.frmMain && parent.frmMain.browseMain && parent.frmMain.browseMain.browseProd)
            {
                // grabbing the info off of the catalog browse/view frameset
                if(parent.frmMain.browseMain.browseProd.document.formProduct)
                {
                    if(parent.frmMain.browseMain.browseProd.document.formProduct.bParLevels)
                    {
                        bParEdit = true;
                        parent.frames.frmTop.document.cartForm.lParDefault.value = parent.frmMain.browseMain.browseProd.document.formProduct.lCurrentParLevelID.value;
                    }
                }
            }
            else
            {
                // grabbing the info off of list or lastreceipt
                if(parent.frmMain && parent.frmMain.document.formProduct)
                {
                    if(parent.frmMain.document.formProduct.bParLevels)
                    {
                        bParEdit = true;
                        parent.frames.frmTop.document.cartForm.lParDefault.value = parent.frmMain.document.formProduct.lCurrentParLevelID.value;
                    }
                }
                else
                {
                    if(document.formProduct)
                    {
                        if(document.formProduct.bParLevels)
                        {
                            bParEdit = true;
                            parent.frames.frmTop.document.cartForm.lParDefault.value = document.formProduct.lCurrentParLevelID.value;
                        }
                    }
                }
            }
            parent.frames.frmTop.document.cartForm.sMainURL.value = sURL;
            if(navigator.userAgent.indexOf("MSIE 5.0") == -1)
                bNavigate = UpdateCartQty(0,0,sURL,bParEdit);
            else
                bNavigate = true;
            if(bNavigate)
                parent.frames.frmMain.window.location = "/access/blank.aspx?" + getFrameworkParameters();
        }
        else
        {
            // for MAC
            parent.frames.frmTop.document.cartForm.sMainURL.value = "";
            bNavigate = UpdateCartQty(0,0,sURL);
            if(bNavigate)
                parent.frames.frmMain.window.location = sURL;
        }
    }
    else
    {
        // Blank the navigate URL
        parent.frames.frmTop.document.cartForm.sMainURL.value = "";
        if(sURL.indexOf("sessionKey") == -1) {
            if(sURL.indexOf("?") == -1)
                sURL += "?" + getFrameworkParameters();
            else
                sURL += "&" + getFrameworkParameters();
        } 
        parent.frames.frmMain.window.location = sURL;
    }
    
}
 
function GetProductHistory(bUseAmpersand)
{
    var sDivID = "";
    // If on browse section, grab stuff for link back
    if(parent.frames.frmMain.frames)
    {
        if(parent.frames.frmMain.frames.length != 4)
            return "";
        else
        {
            if(!parent.frames.frmMain.frames.browseMain.frames.browseProd) return "";
            if(!parent.frames.frmMain.frames.browseMain.frames.browseProd.document.formProduct) return "";
            if(!parent.frames.frmMain.frames.browseMain.frames.browseProd.document.formProduct.lRangeID)
                return "";
            else
            {
                if(parent.frames.frmMain.frames.browseMain.frames.browseProd.document.formProduct)
                {
                    // This check needs to be done for each get because the user may click on
                    // another nav bar during browsing and the form is gone, causing a JScript error
                    if(parent.frames.frmMain.frames.browseMain.browseProd.document.formProduct)
                        var lRangeID    = parent.frames.frmMain.frames.browseMain.browseProd.document.formProduct.lRangeID.value;
                    if(parent.frames.frmMain.frames.browseMain.browseProd.document.formProduct)                     
                        var lBrowseID   = parent.frames.frmMain.frames.browseMain.browseProd.document.formProduct.lBrowseID.value;
                    if(parent.frames.frmMain.frames.browseMain.browseProd.document.formProduct)
                        var lViewID     = parent.frames.frmMain.frames.browseMain.browseProd.document.formProduct.lViewID.value;
                    if(parent.frames.frmMain.frames.browseMain.browseProd.document.formProduct)                     
                        var lFilterID   = parent.frames.frmMain.frames.browseMain.browseProd.document.formProduct.lFilterID.value;
                    if(parent.frames.frmMain.frames.browseMain.browseProd.document.formProduct) {                   
                        if(parent.frames.frmMain.frames.browseMain.browseProd.document.formProduct.sNodeString)
                            var sNodeString = parent.frames.frmMain.frames.browseMain.browseProd.document.formProduct.sNodeString.value;
                    }
                    if(parent.frames.frmMain.frames.browseMenu.frmIDs)
                        sDivID = parent.frames.frmMain.frames.browseMenu.document.frmIDs.sLastDivID.value;
                    if(bUseAmpersand)
                        return "&lDiv=" + sDivID + "&bLinkBack=1&sNodeString=" + escape(sNodeString) + "&lRangeID=" + escape(lRangeID) + "&lBrowseID=" + lBrowseID + "&lViewID=" + lViewID + "&lFilterID=" + lFilterID;
                    else
                        return "?lDiv=" + sDivID + "&bLinkBack=1&sNodeString=" + escape(sNodeString) + "&lRangeID=" + escape(lRangeID) + "&lBrowseID=" + lBrowseID + "&lViewID=" + lViewID + "&lFilterID=" + lFilterID;
                }
            }
        }
    }
    else
        return "";
}
 
function GoRsi()
{
    //if("True" == "True")
    //  parent.location = '/access/custompages/rsi/start.aspx?dc=RH&lMasterLoginID=0&id=&sRSI=&sessionKey=m7OeajwJY422s46HZZMEzl8jRJoMvPtmiXmYMavkHJc60T98rbHhTdBlv%2bcx4cgv7TEnaExyqBLrFWhGBtRuASDM7H1r290LEtRVMjRMmjQjuBoB65qxJ45NGTzUbsvk7BWy8xwQujtyJ%2f5o%2bKsbHpVqxWg8pJx9sBDtra9TmbUVTV3eXribGAv2WjlMpfwd';
    //else
    parent.location = 'http://www.rsiweb.com'
        //parent.location = '/access/RSIPost.aspx?dc=RH&lMasterLoginID=0&id=&sRSI=&sessionKey=m7OeajwJY422s46HZZMEzl8jRJoMvPtmiXmYMavkHJc60T98rbHhTdBlv%2bcx4cgv7TEnaExyqBLrFWhGBtRuASDM7H1r290LEtRVMjRMmjQjuBoB65qxJ45NGTzUbsvk7BWy8xwQujtyJ%2f5o%2bKsbHpVqxWg8pJx9sBDtra9TmbUVTV3eXribGAv2WjlMpfwd';
}
function AddOnChargePrompt(popupType)
{
 
        var bConfirmAddOnCheckout = 'False'; 
        var SubTotal = 0;
        var bPrompt = true;
        //OrderType Set
        var ChargeOrder= 1;
        var SmallOrder= 2;
        var LargeOrder= 3;
        //Ruletype Set
        var Flat1 =3;
        var Flat2 = 4;
        var Percent1 = 5;
        var Percent2 = 6; 
        
        var arrOrder;
        var arrLen = 0;
        var iCnt = 0;
        var iMax = 0;
        var iMin = -1;
        if(parent.frames.frmTop.document.getElementById("cSubtotal"))
        {                   
            SubTotal = parent.frames.frmTop.document.getElementById("cSubtotal").innerHTML.replace("$","").replace(",","");                 
        }
        // Display prompt based on the array for small order upcharge.
        if(parent.frames.frmTop.arrDiscount)
        { 
            arrOrder = parent.frames.frmTop.arrDiscount;
            arrLen =  arrOrder.length;                  
        }           
                
        if(popupType == 'popup2')
        {
                if(parent.frames.frmMain.document.getElementById("checkOutControl_ReturnToCartButton"))
                {       
                    if(bConfirmAddOnCheckout == "True")
                    {       
                            var bDiscountCharge = false; // Flag to check Charges are applied. 
                            //Get Max small order upcharge amount.                          
                            while(iCnt < arrLen)
                            {                                                   
                                if(arrOrder[iCnt][3] == SmallOrder)
                                {
                                    if(!isNaN(parseFloat(arrOrder[iCnt][0])))
                                        iMin = parseFloat(arrOrder[iCnt][0]);
                                    if(!isNaN(parseFloat(arrOrder[iCnt][1])))
                                        iMax = parseFloat(arrOrder[iCnt][1]);
                                    
                                    if(SubTotal >= iMin && SubTotal <= iMax)        
                                        bDiscountCharge = true; //Allow Prompt                                      
                                }
                                if(arrOrder[iCnt][3] == ChargeOrder)
                                {
                                    bDiscountCharge = true; //Allow Prompt 
                                }
                                iCnt++;
                            }
                            
                            if(arrLen == 0 || !bDiscountCharge) //If No Rule is applied
                                bPrompt = false;                    
                            else
                                bPrompt = true;
                                
                                if(bPrompt)
                                {
                                    if(!confirm(' Do you accept the additional charges? \n Click "OK" to accept charges and continue. \n Click "Cancel" to decline charges and return to cart.'))
                                    {                                   
                                        Navigate('button3','/access/cart.aspx','div3');
                                        return false;
                                    }
                                    else
                                    {
                                        parent.frames.frmMain.window.location = "/access/checkout.aspx?state=1&"+ getFrameworkParameters();                                     
                                        return true;
                                    }                       
                                }
                                else
                                {                               
                                        parent.frames.frmMain.window.location = "/access/checkout.aspx?state=1&"+ getFrameworkParameters();
                                    return true;
                                }
                        }
                        parent.frames.frmMain.window.location = "/access/checkout.aspx?state=1&"+ getFrameworkParameters();
                        return true;
                    }
                    
                    return true;
        }
        else
        {
            if((!parent.frames.frmMain.document.getElementById("checkOutControl_ReturnToCartButton")&& !parent.frames.frmMain.document.getElementById("checkOutControl_addonTableCell"))&& (!parent.frames.frmMain.document.getElementById("orderAlertMessage")))
            {   
                    var bDisplay = false;
                    var alertStr = "You may be able to receive an additional discount! \n\n";
                    while(iCnt < arrLen)
                    {
                        if(arrOrder[iCnt][3] == LargeOrder) //Check Large Order Discount
                        {
                            if(arrOrder[iCnt][6] == "True") //Check Alert to display prompt
                            {                                                                               
                                if((arrOrder[iCnt][0]- SubTotal) > 0) //Check the Discount Range
                                {
                                    bDisplay = true;
                                    var diff = Math.abs(arrOrder[iCnt][0]- SubTotal);
                                    if(arrOrder[iCnt][4] == Flat1 || arrOrder[iCnt][4] == Flat2) //Check Flat Fee   
                                    {   
                                        alertStr +=  " If you add $" + diff.toFixed(2) + ", your discount amount will be $" + Math.abs(arrOrder[iCnt][2]).toFixed(2) + " \n";
                                    }
                                    if(arrOrder[iCnt][4] == Percent1 || arrOrder[iCnt][4] == Percent2)// Check percentage   
                                    {
                                        var discount = (arrOrder[iCnt][0] * arrOrder[iCnt][2]) / 100;
                                        alertStr +=  " If you add $" + diff.toFixed(2) + ", your discount amount will be $" + Math.abs(discount).toFixed(2) + " \n";
                                    }
                                }
                            }   
                        }
                        iCnt++;
                    }
                    alertStr +='\n \n Click "OK" to proceed to the Review Order screen.';
                    alertStr +='\n \n Click "Cancel" to return to the cart to edit your order.';
                    if(bDisplay)
                    {
                        if(!confirm(alertStr))
                        {   
                            if(!parent.frames.frmMain.frmCart)
                                Navigate('button3','/access/cart.aspx','div3');
                            return false;
                        }return true;
                    }return true;
            }return true;
        }
        
        return true;
}
</SCRIPT>
<script language='Javascript'>document.getElementById('tdBtnHome').style.display = 'block';document.getElementById('tdBtnAccount').style.display = 'block';document.getElementById('tdBtnOrderMenu').style.display = 'block';document.getElementById('tdBtnCart').style.display = 'block';document.getElementById('tdBtnCheckOut').style.display = 'block';</SCRIPT></TD>
        </TR>
        <TR>
            <TD valign="center" id="logoImage" width="50px"><IMG id='imgDistLogo_RH' src='/assets/images/logos/RH_logo.jpg' border=0></TD>          
            <TD align="right" valign="top" width=100%>
                <TABLE cellpadding="0" cellspacing="0" border="0" height="100%" width="100%" align=right>
                    <TR>
                        <TD>
                            <TABLE cellspacing="0" cellpadding="0" border="0" width="100%">
                                <TR>
                                    <td rowspan=2 valign=bottom align=right width=100% >
                                        <table border="0" width=100% >
                                            <tr>
                                                <td>
                                                    <TABLE border="0" CELLSPACING="0" CELLPADDING="0" align=right width=100%>
                                                        <TR>
                                                            <td align="center" valign="middle" style="font-size:8pt" width=100%>
                                                                <div id='divMessages' style="display:none">
                                                                    <A href='/access/messageboard.aspx?sessionKey=m7OeajwJY422s46HZZMEzl8jRJoMvPtmiXmYMavkHJc60T98rbHhTdBlv%2bcx4cgv7TEnaExyqBLrFWhGBtRuASDM7H1r290LEtRVMjRMmjQjuBoB65qxJ45NGTzUbsvk7BWy8xwQujtyJ%2f5o%2bKsbHpVqxWg8pJx9sBDtra9TmbUVTV3eXribGAv2WjlMpfwd' target="frmMain" onclick="hideNewMessages()" id=newMessagesLink>
                                                                        <IMG src='/assets/images/newMail.gif' border="0" id="newMessagesImage">
                                                                        <span id='newMessagesText'>(0) New&nbsp;Messages</A></span>
                                                                    
                                                                </div>
                                                            </td>
                                                        </TR>
                                                        
                                                    </TABLE>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td>
                                                    <TABLE cellspacing="2" cellpadding="2" border="0" bgcolor="black" id="oOrderEditStatus" align=right 
                                                        style="display:none">
                                                        <TR>
                                                            <TD bgcolor="silver" style="font-size:8pt;font-weight:bold;text-align:center"><NOBR>Order 
                                                                    Edit Mode (<FONT style="font-size:8pt;color:red;" id="oOrderModeID"></FONT>)</NOBR></TD>
                                                            <TD bgcolor="black"><A style="font-size:8pt;font-weight:bold;text-align:center;color:white;" href="Javascript:CancelOrderEdit('')">Cancel</A></TD>
                                                        </TR>
                                                    </TABLE>
                                                </td>
                                            </tr>
                                        </table>
                                    </TD>
                                    <TD  colspan="4" align="right">
                                        <TABLE id=subtotalsTable cellspacing="2" cellpadding="1" border="0" width='100%'>
                                            <TR>
                                                <TD class="titleBarLinks" align="center" width="33%" id="subtotalTitle">&nbsp;Current&nbsp;Subtotal&nbsp;</TD>
                                                
                                                <TD class="titleBarLinks" align="center" width="33%" id="lineItemsTitle">&nbsp;Line&nbsp;Items&nbsp;</TD>
                                                <TD class="titleBarLinks" align="center" width="33%" id="piecesTitle">&nbsp;Pieces&nbsp;</TD>
                                            </TR>
                                            <TR> <TD style='display:none' align='center' id='fakeSubtotal'>$0.00</TD><TD align='center' id='cSubtotal'>$0.00</TD><INPUT id='netcSubtotal' type=hidden value='$0.00'><TD align='center' id='lItems'>0</TD><TD align='center' id='lCartPieces'>0</TD></TR>
                                            <TR>                                                
                                                <TD colspan="4" class="titleBarLinks"><IMG src="/assets/images/blank.gif" height="1"></TD>
                                            </TR>
                                        </TABLE>
                                    </TD>
                                </TR>
                                <TR>
                                    <td></td>                                   
                                    <TD align="right" class="search" align="bottom"><INPUT style="width:150" type="text" id="srch" name="srch" size="17" maxlength="50"></TD>
                                    <TD class="search" align="bottom"><INPUT type='hidden' name='srchType' value='3'></TD>
                                    <TD class="search" align="bottom"><INPUT class="ezbutton" type="button" value="Search" id="SearchBtn" name="SearchBtn" onclick="goSearch();"></TD>
                                </TR>
                            </TABLE>
                        </TD>
                        <TD align="middle" valign="center">
                            <TABLE cellspacing="0" cellpadding="0" border="0">
                                <TR>
                                    <TD><A href="Javascript:RedirectToHelp();" id="helpLink"><IMG src="/assets/images/helpnotext.gif" title="Help" border="0" id="helpImage"></A></TD>
                                </TR>
                                <TR>
                                    <TD><IMG src="/assets/images/blank.gif" height="5" border="0"></TD>
                                </TR>
                                <TR>
                                    <TD><A id=logonoutLink href="javascript:Logout('http://www.rsiweb.com');"><IMG src='/assets/images/logoutnotext.gif' title='Logout' border='0' id=logoutImage></A></TD>
                                </TR>
                            </TABLE>
                        </TD>
                    </TR>
                </TABLE>
            </TD>
        </TR>
    </TABLE>
    <INPUT type="hidden" name="bSearch" value="1"> <INPUT type="hidden" name="bLinkBack">
    <INPUT type="hidden" name="lViewID"> <INPUT type="hidden" name="lBrowseID"> <INPUT type="hidden" name="lRangeID">
    <INPUT type="hidden" name="sNodeString"> <INPUT type="hidden" name="lDiv"> <INPUT type="hidden" name="lOrderID">
    <INPUT type="hidden" name="sPONumber"> <INPUT type="hidden" name="lDelTypeID"> <INPUT type="hidden" name="sRoutingDate">
    <INPUT type="hidden" name="sSpecialInst"> <INPUT type="hidden" name="lProdID"> <INPUT type="hidden" name="computer" value="Unit_05">
    <INPUT type="hidden" name="lid"><INPUT type="hidden" name="lSortID"><INPUT type="hidden" name="lParDefault">
    <INPUT type="hidden" name="bContinueSearch">
    <input type='hidden' name='sessionKey' value='m7OeajwJY422s46HZZMEzl8jRJoMvPtmiXmYMavkHJc60T98rbHhTdBlv+cx4cgv7TEnaExyqBLrFWhGBtRuASDM7H1r290LEtRVMjRMmjQjuBoB65qxJ45NGTzUbsvk7BWy8xwQujtyJ/5o+KsbHpVqxWg8pJx9sBDtra9TmbUVTV3eXribGAv2WjlMpfwd' />
</FORM>
<FORM name="cartForm" id="ocartForm" action="frmmessage.aspx?act=1&sessionKey=m7OeajwJY422s46HZZMEzl8jRJoMvPtmiXmYMavkHJc60T98rbHhTdBlv%2bcx4cgv7TEnaExyqBLrFWhGBtRuASDM7H1r290LEtRVMjRMmjQjuBoB65qxJ45NGTzUbsvk7BWy8xwQujtyJ%2f5o%2bKsbHpVqxWg8pJx9sBDtra9TmbUVTV3eXribGAv2WjlMpfwd" method="post" target="frmMessage">
    <INPUT type="hidden" name="sXmlCart"> <INPUT type="hidden" name="sMainURL"> <INPUT type="hidden" name="lParDefault">
    <INPUT type="hidden" name="bLogout" value="0">
    <INPUT type='hidden' name='bSessionflag' value="1">
</FORM>
<form name="_ctl0" method="post" action="frmtop.aspx?sHome=frmbrowse.aspx&amp;id=fGI5wbZJLmMU9ZiRXi3dgjkDi5qDK5nsWavxs27vtlQAY3NEGd4U63H2ZeP8RnmNl7sb/VTGYB8=&amp;sRSI=&amp;sessionKey=m7OeajwJY422s46HZZMEzl8jRJoMvPtmiXmYMavkHJc60T98rbHhTdBlv%2bcx4cgv7TEnaExyqBLrFWhGBtRuASDM7H1r290LEtRVMjRMmjQjuBoB65qxJ2NE6kaaSgjFyXY3NR15vxykNy%2bjSp39I3qKkWIyo%2faDfM7s1XDU4lU6eIqlShzsZPErvVAa6QX%2b" id="_ctl0">
<input type="hidden" name="__VIEWSTATE" value="dDwtMTk5ODUzNjAxNzs7PgpPWS+h82qakidIWGbac5V3DgYL" />
    <script language='javascript'><!--
                            function getFrameworkParameters() {
                                var frameworkParameters;
                                try {
                                    frameworkParameters = FireNamedWindowScript('UIFW_MainPage', 'UIFW_GetFrameworkParameters()');
                                } catch(e) {
                                    frameworkParameters = '';
                                }
                                if (frameworkParameters == '') {
                                    frameworkParameters = 'sessionKey=m7OeajwJY422s46HZZMEzl8jRJoMvPtmiXmYMavkHJc60T98rbHhTdBlv%2bcx4cgv7TEnaExyqBLrFWhGBtRuASDM7H1r290LEtRVMjRMmjQjuBoB65qxJ45NGTzUbsvk7BWy8xwQujtyJ%2f5o%2bKsbHpVqxWg8pJx9sBDtra9TmbUVTV3eXribGAv2WjlMpfwd';
                                }
                                return frameworkParameters;
                            }
                            function FireNamedWindowScript(strName, strFunctionName) {
                                try {
                                    if (!(new String(self.name) == 'undefined') && (self.name == strName)) {
                                        return eval(strFunctionName + ';');
                                    } else {
                                        if (top != self) {
                                            return parent.FireNamedWindowScript(strName, strFunctionName);
                                        } else if (!(new String(opener) == 'undefined')) {
                                            return opener.FireNamedWindowScript(strName, strFunctionName);
                                        } else {
                                            return '';
                                        }
                                    }
                                } catch(e) {
                                    return '';
                                }
                            }
                        //--></script>
 
    <script language='javascript'><!--
                    function updateFrameworkParameters(frameworkParameters) {
                        var nameValuePairs = frameworkParameters.split('&');
                        for (var i = 0; i < nameValuePairs.length; i++) {
                            var nameValuePair = nameValuePairs[i].split('=');
                            document.all(nameValuePair[0]).value = unescape(nameValuePair[1]);
                        }
                    }
                    //--></script>
 
    <script language='javascript'><!--
                                        FireNamedWindowScript('UIFW_MainPage', 'UIFW_SetFrameworkParameters(\'sessionKey=m7OeajwJY422s46HZZMEzl8jRJoMvPtmiXmYMavkHJc60T98rbHhTdBlv%2bcx4cgv7TEnaExyqBLrFWhGBtRuASDM7H1r290LEtRVMjRMmjQjuBoB65qxJ45NGTzUbsvk7BWy8xwQujtyJ%2f5o%2bKsbHpVqxWg8pJx9sBDtra9TmbUVTV3eXribGAv2WjlMpfwd\')');
                                    //--></script>
 
</form>
 
<script language='Javascript' src='/access/script/frmTop.js'></SCRIPT>
<script language="Javascript"> 
//Start Changes Z.S. 05/04/2007
var bCancelEdit = 'False';
window.onbeforeunload=ClearOrder;
function ClearOrder()
{
    // Checks whether the user has activated a new account and avoids destroying the session    
    if(document.getElementById('bSessionflag').value  == 1)
    {
        if (window.event.clientY < 0)
        {       
            if (bCancelEdit=='True')
            {
                var orderId = GetOrderEditCookie();
                ClearOrderInfo();
                // Send request to remove all items //Start U.S.N 06/28/2007    
                parent.frmMessage.location = sMsgPage + "?bClearAll=1&orderId=" + orderId + "&act=9&" + getFrameworkParameters();
                // Update the values in the frame and xml
                UpdateCart(0,0,0,true);
            }
            else
            {
                parent.frmMessage.location = sMsgPage + "?bClearAll=1&" + getFrameworkParameters();     //End U.S.N 06/28/2007      
            }
        }
    }
}
//End Changes Z.S. 05/04/2007
var elogon = 'False';
var bHide = false; //Hides the Order Edit Mode.
// Not releasing the new framework for 3.74 because it only has one necessary change
// for terms of use (Duenas) uncomment the line below and delete the following for 3.75 (Terms of Use)
var tou = '0';
var newMessages = '0';
var bAddOnExit = 'False';
var cartItems = '0';
TermsOfUse()
checkForBadBrowser()
 
// If there is a need for the merge cart dialog to be displayed this server function will insert javascript
// to call it.
 
 
// This function will display the merge cart dialog.  This is used for CBORD cart upload feature.
// This will allow the user to select how to handle the cart upload if there are existing items
// in the cart.
function MergeCartDialog()
{
    var choice = null;
    if (cartItems > 0) //BUG14974
    {
        choice = window.showModalDialog('/access/MergeCartDialog.aspx?' + getFrameworkParameters(), window, "dialogHeight:300px;dialogWidth:500px;status:no;center:yes;fixed:yes;scroll:no;unadorned:yes");
    }
    else
    {
        choice = "Merge"; //BUG14974 'just upload the items
    }
    if(choice == null)
        choice = "Cancel";
        
    if (newMessages > 0 && choice != "Cancel")
        alert('You have ' + newMessages + ' new messages.');
    
    if(choice == "Cancel")
    {
        // Send them out
        top.location = 'http://www.rsiweb.com';
    }
    else if(choice == "Merge")
    {
        // Go to the validate upload page
        parent.frames.frmMain.location = "/access/validateupload.aspx?" + location.search.substring(1);
        
    }
    else if(choice == "Clear")
    {
        // Clear the cart
        parent.frmMessage.location = 'frmmessage.aspx?act=9&' + getFrameworkParameters();
        // Go to validate upload page
        parent.frames.frmMain.location = "/access/validateupload.aspx?" + location.search.substring(1);
    }
}
 
function TermsOfUse()
{
    var accept = null;
    if (tou > 0 && GetCookie("DL") == null)
    {
        var myValues = new Object();
        myValues.id = tou;
 
        while (accept == null)
        {           
            accept = window.showModalDialog('/access/termsofuse.aspx?tou=' + tou + '&' + getFrameworkParameters(),myValues,"dialogHeight: 565px; dialogWidth: 750px; edge: Sunken; center: Yes; help: No; resizable: No; status: No;");
        }
    
        //Log to database
        if(accept == null) //if user closes the window set accept to no BUG13926
            accept = "no";
            
        //Send value to message for logging or action of some kind
        parent.frmMessage.location = 'frmmessage.aspx?act=45&accept=' + accept + '&' + getFrameworkParameters();
            
        //Open site or redirect
        if(accept == "yes" || accept == "remind")
        {
            parent.document.getElementById("mainFrameSet").rows = "100,20,*,15";
            RecursiveCallBack("parent.frames('frmFooter').document.getElementById('mainBody')", 'block')
            RecursiveCallBack("parent.frames('frmFooter').document.getElementById('grebuild')", 'none')
        }
        else
        {
            top.location = 'http://www.rsiweb.com';
        }
    }
    else
    {
        parent.document.getElementById("mainFrameSet").rows = "100,20,*,15";
        RecursiveCallBack("parent.frames('frmFooter').document.getElementById('mainBody')", 'block')
    }
    //Set location to standard home page
    parent.frames.frmMain.location = "/access/frmbrowse.aspx?sHome=frmbrowse.aspx&id=fGI5wbZJLmMU9ZiRXi3dgjkDi5qDK5nsWavxs27vtlQAY3NEGd4U63H2ZeP8RnmNl7sb/VTGYB8=&sRSI=&sessionKey=m7OeajwJY422s46HZZMEzl8jRJoMvPtmiXmYMavkHJc60T98rbHhTdBlv%2bcx4cgv7TEnaExyqBLrFWhGBtRuASDM7H1r290LEtRVMjRMmjQjuBoB65qxJ2NE6kaaSgjFyXY3NR15vxykNy%2bjSp39I3qKkWIyo%2faDfM7s1XDU4lU6eIqlShzsZPErvVAa6QX%2b";
    //If messages go to notify.
 
    //Start U.S.N 12/11/2006
    CheckForOrderInProgress(accept);
    //if(newMessages > 0 && accept != 'no' && elogon == 'False')
    //  newMessageNotify()
    //End U.S.N 12/11/2006
}
 
function hideNewMessages()
{
    document.all.divMessages.style.display = "none";
}
 
function newMessageNotify()
{
    if (confirm('You have ' + newMessages + ' new messages.  Click OK to read them now.'))
    {  var oLoc = "/access/messageboard.aspx?" + getFrameworkParameters();
        hideNewMessages();
        parent.frames.frmMain.location = oLoc;
    }
}
 
 
function RecursiveCallBack(sObject, sStyle)
{
    try
    {
        newObject = eval(sObject);
        if (newObject == null)
        {
            setTimeout("RecursiveCallBack(\"" + sObject.toString() + "\", '" + sStyle.toString() + "')", 250);
        }
        else
        {   
            newObject.style.display = sStyle.toString();
        }
    }
    catch (err)
    {
        CreateErrorInformation(err,"RecursiveCallBack")
    }
    
    
}
function CancelOrderEdit(orderId)
{   
    //Start changes by Z.S 12/06/2006
    orderId = GetOrderEditCookie();
    //End changes by Z.S 12/06/2006
    bConfirm = window.confirm("Are you sure you want to cancel editing order " + orderId + "?")     
    if(bConfirm)
    {
        ClearOrderInfo();
        // Send request to remove all items     
        parent.frmMessage.location = sMsgPage + "?orderId=" + orderId + "&act=9&" + getFrameworkParameters();               
        // Update the values in the frame and xml
        UpdateCart(0,0,0,true);
        // Because we are updating the cart with 0's we clear the cart dom
        EraseCartDom(true);
        if(parent.frmMain)
        {
            var sLoc = new String(parent.frmMain.location);
            if(sLoc.indexOf("cart.aspx") > -1 || sLoc.indexOf("checkout.aspx") > -1)
                setTimeout("parent.frmMain.location = 'cart.aspx?sessionKey=m7OeajwJY422s46HZZMEzl8jRJoMvPtmiXmYMavkHJc60T98rbHhTdBlv%2bcx4cgv7TEnaExyqBLrFWhGBtRuASDM7H1r290LEtRVMjRMmjQjuBoB65qxJ45NGTzUbsvk7BWy8xwQujtyJ%2f5o%2bKsbHpVqxWg8pJx9sBDtra9TmbUVTV3eXribGAv2WjlMpfwd'", 1000);
        }
    }
}
 
function checkForBadBrowser(sSite)
{
    var sQS = "";
    var bBadBrowser = false;
    var bBadFeature = false;
    var bReminder   = false;
    //sSite (community or access) is for community or access
    var sVersion = window.navigator.userAgent;
 
    // First try to get IE version
    if(sVersion.indexOf("MSIE") == -1)
    {
        // They are using a non-Microsoft browser (make sure it's at least Netscape 6.2 or better)
        if (sVersion.indexOf("Netscape6") == -1 && sVersion.indexOf("Netscape/7") == -1)
            bBadBrowser = true;
        else
        {
            // Make sure it's at least 6.2
            lVersion = 7;
            if (sVersion.indexOf("Netscape6") > -1)
            {
                var lVersionIndex = sVersion.indexOf("Netscape6/")
                lVersion = sVersion.substring(lVersionIndex + 10, sVersion.length);
            }
            if(sSite == "community")
                bBadBrowser = true; // We do not allow non-microsoft browsers into the community
            if(lVersion < "6.2")
                bBadBrowser = true;
        }
    }
    else
    {
        // Get IE version information
        var lVersion = sVersion.substring(sVersion.indexOf("MSIE") + 5, sVersion.indexOf(";", sVersion.indexOf("MSIE")))
        // Minimum IE requirements for all applications is IE 5 or better
        if(lVersion < "5")
            bBadBrowser = true;
    }
    //if(bAddOnExit == "0")
    //  bBadFeature = true;
    // See if we need to pop the information window
    if(bBadBrowser)
        sQS += "&bR=1";
    //if(bBadFeature)
    //  sQS += "&bF=1";
    //if(bReminder)
    //  sQS += "&bD=1";
    if(bBadBrowser || bBadFeature)
        PopUpWin("browser.aspx?dc=RH" + sQS, 500, 500)
}
 
function EditOrder(lRecID)
{
    //This function is used for hilton punch though order edit. Write the order edit cookie and get the product for the order.
    //Set the cookie
    //setCookie("lOrderEditRecID_" + GetCookie("LI"), lRecID);
    SetOrderEditCookie(lRecID);
    //Used to populate cart times for an order ... this is specific to cXML operators.
    // Pur johns request the cart is always cleard for this operators when editing an order.
    setTimeout("parent.frmMessage.location = 'frmmessage.aspx?act=22&lRecID=" + lRecID + "&bClear=Yes&" + getFrameworkParameters() + "'", 1000);
}
 
//This was added for bug13037 //BUG13465 changed event so we dont' get 2 popups also added check for active element...if textbox is active...auto submit calls gosearch for us.
document.onkeydown = KeyPress;
function KeyPress()
{   
    if(window.event.keyCode == 13 && document.activeElement.id == "srch")
    {
        if(document.getElementById("SearchBtn").disabled == false)
        {
            goSearch();         
            return false; //Changes done by V.G. 08/01/2007
        }
        else
        {
            window.event.returnValue = false;
        }   
    }
}
//Start U.S.N 12/11/2006
function CheckForOrderInProgress(accept)
    {
        var bHilton = 'False';
        // Store the cookie using the logonID to make sure we don't get mixed up
        var lOrderID = '';
        if (bHilton == "False") //DO not show the popup for hilton clients. per john S request.
        {
        
            if(lOrderID.length > 0)
            {
                var sQS = "";
                sQS = "?bCurrentlyEditingOrder=true";
                sQS += "&lCurrentlyEditingOrderID=" + lOrderID;
                sQS += "&bJustLoggedIn=true";
                sQS += "&" + getFrameworkParameters();
                var bNS = (window.Event) ? 1 : 0;
                // Pass in flags so popup can display the options correctly
                
                if(!bNS)
                {
                    // We need to let them know about the order in progress and give them options
                    var sAction = window.showModalDialog("popupOrderEditOptions.aspx" + sQS, window, "dialogHeight:250px;dialogWidth;270px;status:no;center:yes;");
                    ProcessOrderEditAction(sAction,accept);
                }
                else
                {
                    // Just pop window for netscape (it will call the process action when ready)
                    PopUpWin("popupOrderEditOptions.asp" + sQS, 400, 250);
                }
                
            }
            else
            {
                //Start U.S.N 12/11/2006
                if(newMessages > 0 && accept != 'no' && elogon == 'False')
                    newMessageNotify();
                //End U.S.N 12/11/2006
            }
        }
    }
    function ProcessOrderEditAction(sAction,accept)
    {
        switch(sAction)
        {
            case "ResumeInProgressEdit" :
                //Start U.S.N 12/11/2006
                if(newMessages > 0 && accept != 'no' && elogon == 'False')
                    newMessageNotify();
                //End U.S.N 12/11/2006
                parent.frmMain.document.location = "cart.aspx?" + getFrameworkParameters();
                break;
            case "CancelInProgress" :
                //Start U.S.N 12/11/2006
                if(newMessages > 0 && accept != 'no' && elogon == 'False')
                    newMessageNotify();
                //End U.S.N 12/11/2006
                SetOrderEditCookie("");
                bHide = true;
                break;
            case "Cancel" :
                //Start U.S.N 12/11/2006
                if(newMessages > 0 && accept != 'no' && elogon == 'False')
                    newMessageNotify();
                //End U.S.N 12/11/2006
                break;
        }   
    }//End U.S.N 12/11/2006
</SCRIPT>
<script language='Javascript'>DeleteCookie('lOrderEditRecID_149442');
</SCRIPT>
<script language='Javascript'> 
//Start U.S.N 12/12/2006
if (bHide)
{
    document.getElementById('oOrderEditStatus').style.display = 'none';
    ClearOrderInfo();
    // Send request to remove all items 
    parent.frmMessage.location = sMsgPage + "?orderId=" + '' + "&act=9&" + getFrameworkParameters();                
    // Update the values in the frame and xml
    UpdateCart(0,0,0,true);
    // Because we are updating the cart with 0's we clear the cart dom
    EraseCartDom(true);
    if(parent.frmMain)
    {
        var sLoc = new String(parent.frmMain.location);
        if(sLoc.indexOf("cart.aspx") > -1 || sLoc.indexOf("checkout.aspx") > -1)
            setTimeout("parent.frmMain.location = 'cart.aspx?sessionKey=m7OeajwJY422s46HZZMEzl8jRJoMvPtmiXmYMavkHJc60T98rbHhTdBlv%2bcx4cgv7TEnaExyqBLrFWhGBtRuASDM7H1r290LEtRVMjRMmjQjuBoB65qxJ45NGTzUbsvk7BWy8xwQujtyJ%2f5o%2bKsbHpVqxWg8pJx9sBDtra9TmbUVTV3eXribGAv2WjlMpfwd'", 1000);
    }
}//End U.S.N 12/12/2006
</SCRIPT>
 
</HEAD>
Edited by mpcluever

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Try this, seemed to work for me (submits the form):

#include "IE.AU3"

$RSI_Username="testName"
$RSI_Password="testPassword"

$oIE = _IECreate("http://www.amphire.com/access/custompages/rsi/logon.aspx")
$oForm = _IEFormGetObjByName($oIE, "formLogon")
$oText = _IEFormElementGetObjByName($oForm, "vsLogonName")
_IEFormElementSetValue($oText, $RSI_Username)
$oPassword = _IEFormElementGetObjByName($oForm, "vsPassword")
_IEFormElementSetValue($oPassword, $RSI_Password)
_IEFormSubmit($oForm)

edit: Nevermind I got the pages mixed up...Leme' try on the page source you provided...

Edited by evilertoaster

Share this post


Link to post
Share on other sites

On a local copy of the page source you provided, this works for clicking the button:

$AccountButton = _IEGetObjById($oIE,'button1')
_IEAction($AccountButton, "click")

Share this post


Link to post
Share on other sites

Hmmm. Still not working on the actual site. I'll keep playing with it. Thanks!!

From Scite window:

>"C:\Program Files\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /run /prod /ErrorStdOut /in "R:\Scripts\Company Scripts\RedKing\RSI Amphire.au3" /autoit3dir "C:\Program Files\AutoIt3" /UserParams    
+>15:00:10 Starting AutoIt3Wrapper v.1.10.1.8    Environment(Language:0409  Keyboard:00000409  OS:WIN_XP/Service Pack 3  CPU:X86)
>Running AU3Check (1.54.19.0)  from:C:\Program Files\AutoIt3
+>15:00:11 AU3Check ended.rc:0
>Running:(3.3.6.0):C:\Program Files\AutoIt3\autoit3.exe "R:\Scripts\Company Scripts\RedKing\RSI Amphire.au3"    
--> IE.au3 V2.4-0 Warning from function _IEGetObjById, $_IEStatus_NoMatch (button1)
--> IE.au3 V2.4-0 Error from function _IEAction, $_IEStatus_InvalidDataType
+>15:00:29 AutoIT3.exe ended.rc:0
>Exit code: 0    Time: 20.281

Full Autoit script:

#include <IE.au3>
#include "R:\Scripts\Include\Company Info\Company Select Auto.au3"

$oIE = _IECreate("http://www.amphire.com/access/custompages/rsi/logon.aspx")
$oForm = _IEFormGetObjByName($oIE, "formLogon")
$oText = _IEFormElementGetObjByName($oForm, "vsLogonName")
_IEFormElementSetValue($oText, $RSI_Username)
$oPassword = _IEFormElementGetObjByName($oForm, "vsPassword")
_IEFormElementSetValue($oPassword, $RSI_Password)
_IEFormSubmit($oForm)
_IELinkClickByText($oIE, "Distributor Ordering")
Sleep(10000)
$AccountButton = _IEGetObjById($oIE, 'button1')
_IEAction($AccountButton, "click")

Share this post


Link to post
Share on other sites

were you able to resolve this ? I have read so many posts, but no real answer for this one .. atleast what others suggested is not working for me.

I tried many things, like WinWaitActive, WinActivate, ControlClick, IEAction but no use.

here is my code ( simplified case )

TEST.HTML

----------

<HTML>
<script>
function test()
{
    if(confirm("OK??"))
        location.href="test2.html";
}
</script>
 <BODY>
  HI
  <a href="#" onclick="test()">Test Link</a>
 </BODY>
</HTML>

TEST2.HTML

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

<HTML>
 <BODY>
  Test 2
 </BODY>
</HTML>

AutoIt script

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

$oIE = _IECreate ("http://localhost/test.html")
_IELinkClickByText($oIE,"Test Link")
WinWaitActive("[TITLE:Microsoft Internet Explorer; CLASS:#32770; ]","OK??")
ControlClick("[TITLE:Microsoft Internet Explorer;CLASS:#32770]", "OK??", "[CLASS:Button; TEXT:OK; INSTANCE:1]")
Exit

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

This is the first result on google, so I'm posting it here. I'll also link here from a few other posts I've found.

So from my learnings, what happens is the JavaScript behind the button registers an event handler, that looks specifically for the proper browser events to click the button, then fires the code. the IE functions don't use this (they must use some standard non-JavaScript way of doing it) so we have to create the event ourselves.

;Create an event
$oClickEvent = $oIE.document.createEvent('MouseEvents')
;Event types are 'mouseover', 'mousedown', 'mouseup', and 'click'
$oClickEvent.initEvent('click', true, true)
;Now that we have the event, we send it to the control we want
$oElement.dispatchEvent ($oClickEvent)
;If need be, do this multiple times for mouseover, mousedown, mouseup, and click to simulate a more natural click

source information:
https://stackoverflow.com/questions/24025165/simulating-a-mousedown-click-mouseup-sequence-in-tampermonkey
https://stackoverflow.com/questions/27176983/dispatchevent-not-working-in-ie11

Hope someone found this helpful, I've been looking for this for a loooooooong time.

Edit: I also found out there is an easy way to see what events a button/link/element handles!
7sHnauw.png
Press F12 to open the developer tools, and select the element in the DOM Explorer, then check the Events tab in the right pane. This is SUPER useful! No need to guess what it's expecting!

Edited by corgano
1 person likes this

0x616e2069646561206973206c696b652061206d616e20776974686f7574206120626f64792c20746f206669676874206f6e6520697320746f206e657665722077696e2e2e2e2e

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