Jump to content

How to get name of IE page element?


unity06
 Share

Recommended Posts

Hi Guys

I am still relatively new to autoit.

Have been trying to automate IE with limited success.

But I have a question,

I made a bot which tabs around the page and uses the status bar to identify various links, as it tabs around, it reads from status bar.

But when bot runs onto a form entry box, status bar reads nothing.

For instance on google page.

The main entry box for search.

How to get the name of it?

Is there some way, to get its name while its highlighted/active?

Like Get name of active element/control?

I hope it makes sense, because I am getting pretty good at making it work with this tabbing method. Its just I am stuck with this bit, as status bar only shows links, but not names of entry boxes.

Thanks

Link to comment
Share on other sites

have a look in the the help file for _IEFormElementSetValue  (examples at foot of that document)

  • get the firebug addon for firefox
  • go to www.wikihow.com/macrame
  • right click on the search box at the top
  • select Inspect Element with Firebug
  • check out the html for the form you want in the firebug window

 

In this case it's:

<form id="cse-search-box" action="/Special:GoogSearch">
  <div>
    <input type="hidden" value="008953293426798287586:mr-gwotjmbs" name="cx">
    <input type="hidden" value="FORID:10" name="cof">
    <input type="hidden" value="UTF-8" name="ie">
    <input type="text" x-webkit-speech="" class="search_box" value="" size="30" name="q" id="cse_q">
    <input type="submit" onclick="gatTrack(&quot;Search&quot;,&quot;Search&quot;,&quot;Custom_search&quot;);" onmouseout="button_unswap(this);" onmouseover="button_swap(this);" class="search_button" value="Search" id="cse_sa">
  </div>
</form>

So then this is the code to write something into the search box:

#include <IE.au3>

$oIE = _IECreate("www.wikihow.com/Macrame")     ;open page in IE and get a handle to it
Local $oForms = _IEFormGetCollection($oIE,1)            ;get handle to form: 1 means get 2nd form on page
Local $oQuery = _IEFormElementGetCollection($oForms,3)  ;get handle to element: 3 means 4th element of that form
_IEFormElementSetValue($oQuery,"Organic Lambswool Mirkin Patterns") ;put what you want into the field

Remember the numbering starts at zero so element 4 has index number 3. 

Edited by gruntydatsun
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...