Jump to content
Sign in to follow this  
Allenshill

Use IE.au3 to click a button that has no name or ID

Recommended Posts

Allenshill

I am stumped. I have searched the forums with no help. I am trying to "click" a button that uses a "On Click" action, but it is not in a form, and has no aparent name or ID. Any help would be apreciated, Thanks. Below is a snip of the source.

The button I am trying to click is

<button onclick="document.exportstatus.location.href='Access_export_blank.asp?begin=1';this.disabled='1';document.getElementById('wait').src='../../graphics/processing.gif'">Begin Export</button>

CODE
<TABLE CELLSPACING="0" CELLPADDING="0" BORDER="0">

<TR>

<td VALIGN="TOP">

<TABLE width="200px" height="100%" STYLE="background: #D4D0C8; border-left: 1px solid #FFFFFF; border-top: 1px solid #FFFFFF;" ID="Table2">

<tr>

<td>

<TABLE CELLSPACING="0" CELLPADDING="0" BORDER="0" ID="Table1">

<TR>

<TD WIDTH="2"><IMG SRC="/nfirs/graphics/tab_top_left.gif" WIDTH="2" HEIGHT="2" BORDER="0" ALT=""></TD>

<TD STYLE="border-top: 1px solid #404040;"><IMG SRC="/nfirs/graphics/transparent.gif" WIDTH="50" HEIGHT="1" BORDER="0" ALT=""></TD>

<TD ALIGN="right" WIDTH="2"><IMG SRC="/nfirs/graphics/tab_top_right.gif" WIDTH="2" HEIGHT="2" BORDER="0" ALT=""></TD>

</TR>

<TR>

<TD STYLE="border-left: 1px solid #404040;"><IMG SRC="graphics/transparent.gif" WIDTH="1" HEIGHT="1" BORDER="0" ALT=""></TD>

<TD ID="tab_multi" STYLE="cursor: hand; font-size: 10px; background: #D4D0C8; padding-right: 2px; border-right: 1px solid #404040;" onmouseover="this.style.background='#ECE6DA'" onmouseout="this.style.background='#D4D0C8'" COLSPAN="2" ALIGN="center"><STRONG>History</STRONG></TD>

</TR>

</table>

</td>

</tr>

</table>

<TABLE width="200px" height="100%" STYLE="background: #D4D0C8; border-left: 1px solid #FFFFFF; border-top: 1px solid #FFFFFF;" ID="Table3">

<tr>

<td>

<div STYLE="height: 500px;">

<a href="/File.aspx?FileGuid={4FD71E17-BF72-42DD-9849-838DD03ED99E}">08 Jan 2008 17:31&nbsp;-&nbsp;1005&nbsp;Kilobytes</a><br>

<a href="/File.aspx?FileGuid={9394C646-8E79-4ACB-9FFD-08BE5A06E68B}">08 Jan 2008 16:13&nbsp;-&nbsp;997&nbsp;Kilobytes</a><br>

<a href="/File.aspx?FileGuid={CD69298B-1E55-47C6-8EE0-A2AF99E60712}">08 Jan 2008 13:14&nbsp;-&nbsp;989&nbsp;Kilobytes</a><br>

</div>

</td>

</tr>

</table>

</td>

<TD VALIGN="top" width=100% STYLE="background:#F6F4E8;; padding-left:20px; padding-top:10px; border-left: 1px solid #808080">

<div STYLE="WIDTH: 400px;">

<B>MS Access Data Export</B><BR><BR>

This tool will export all your departments data to an Microsoft Access database.

At the end of the process you will be provided with a link to download this file.

You can then use Access as your report

generator, or export directly from Access to another report application.

<BR><BR>

After you click the Begin Export button, you will see a status bar slowly fill. The processing time on this request can take a few minutes, please be patient.

<BR><BR>

</div>

<button onclick="document.exportstatus.location.href='Access_export_blank.asp?begin=1';this.disabled='1';document.getElementById('wait').src='../../graphics/processing.gif'">Begin Export</button> <BR><BR>

<IMG ID="wait" SRC="../../graphics/transparent.gif" ALT="Bit Processor" HEIGHT="40" WIDTH="400" BORDER="0" STYLE=""><BR>

<iframe NAME="exportstatus" SRC="Access_export_blank.asp" STYLE="margin-top: 20px; width: 400px; Height: 250px;" FRAMEBORDER="0"></iframe>

<BR>

<!--<A HREF="../../imageuploads/logfile.txt" TARGET="_blank">Log File</A>-->

</TD>

</TR>

</table>

Share this post


Link to post
Share on other sites
rbhkamal

It should be something like this:

#include<IE.au3>
$__oIE = IE OBJECT


$__oForm = _IEFormGetCollection($__oIE , 0)
If @error Or Not IsObj($__oForm) Then
    Exit
EndIf

$__oCollection = _IEFormElementGetCollection( $__oForm )
$__oItem = ""
For $__oItem In $__oCollection
    If $__oItem.value == "Begin Export" Then
        $__oItem.click
        Sleep( 100 )
        ExitLoop
    EndIf
Next

_IELoadWait( $__oIE )

Edit: I'm not sure if it's $__oItem.value or $__oItem.name. Also not that your page MUST have a form.

Edited by rbhkamal

"When the power of love overcomes the love of power, the world will know peace"-Jimi Hendrix

Share this post


Link to post
Share on other sites
DaleHohm

Your approach is sound, but the details are not...

<button> is actually not a form element (this is historical - it would make sense, but button was added to HTML long after FORM).

So, you can use the same approach with $oButtons = _IETagNameGetCollection($oIE, "button"), then look therough the elements (For $oButton in $oButtons) as you did and check the value of _IEPropertyGet($oButton, "innertext")

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
Allenshill

Thanks for the help. It worked like a charm. I was on the right track, but I could not figgure out which property to use. Now that you point it out it is quite obvious.

CODE
$oButtons = _IETagNameGetCollection($oIE, "button")

For $oButton in $oButtons

$oButtonTxt=_IEPropertyGet($oButton, "innertext")

if $oButtonTxt="Begin Export" Then

$oButton.click

EndIf

Next

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  

×