Sign in to follow this  
Followers 0
ArmandoXS

Using _IE

5 posts in this topic

Hey guys, I'm currently trying to hone my skills a bit more by manipulating the IE functions to submit data on webpages. I think this would be much more effective then using movemouse, or mouseclick etc... However I cannot even get the sample code to work myself listed in a few _IE examples such as _IEFormElementGetObjByName. 

code reproduced here:

; *******************************************************
; Example 1 - Get a reference to a specific form element by name.
;               In this case, submit a query to the Google search engine
; *******************************************************

#include <IE.au3>

Local $oIE = _IECreate("http://www.google.com")
Local $oForm = _IEFormGetObjByName($oIE, "f")
Local $oQuery = _IEFormElementGetObjByName($oForm, "q")
_IEFormElementSetValue($oQuery, "AutoIt IE.au3")
_IEFormSubmit($oForm)
 

When I run the code i recieve these errors:

--> IE.au3 V2.4-0 Warning from function _IEFormGetObjByName, $_IEStatus_NoMatch
--> IE.au3 V2.4-0 Error from function _IEFormElementGetObjByName, $_IEStatus_InvalidDataType
--> IE.au3 V2.4-0 Error from function _IEFormElementSetValue, $_IEStatus_InvalidDataType
--> IE.au3 V2.4-0 Error from function _IEFormSubmit, $_IEStatus_InvalidDataType
 
I've spent hours trying to find a solution even considering changing the f and q to the names i found digging around on the google website, even utilizing _IELoadWait,  however i recieved the same errors.
 
If not maybe theres another method to accomplish something like this?

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

That's because the form name has changed from "f" to "gbqf".

; *******************************************************
; Example 1 - Get a reference to a specific form element by name.
;               In this case, submit a query to the Google search engine
; *******************************************************

#include <IE.au3>

Local $oIE = _IECreate("http://www.google.com")
Local $oForm = _IEFormGetObjByName($oIE, "gbqf")
Local $oQuery = _IEFormElementGetObjByName($oForm, "q")
_IEFormElementSetValue($oQuery, "AutoIt IE.au3")
_IEFormSubmit($oForm)

If you are worried that the name of the form may change, and you are more confident that the index of the form will remain the same, you can accomplish the same thing using an index instead of a name:

#include <IE.au3>

Local $oIE = _IECreate("http://www.google.com")
Local $oForm = _IEFormGetCollection($oIE, 0)
Local $oQuery = _IEFormElementGetObjByName($oForm, "q")
_IEFormElementSetValue($oQuery, "AutoIt IE.au3")
_IEFormSubmit($oForm)
Edited by danwilli

Share this post


Link to post
Share on other sites

 

That's because the form name has changed from "f" to "gbqf".

; *******************************************************
; Example 1 - Get a reference to a specific form element by name.
;               In this case, submit a query to the Google search engine
; *******************************************************

#include <IE.au3>

Local $oIE = _IECreate("http://www.google.com")
Local $oForm = _IEFormGetObjByName($oIE, "gbqf")
Local $oQuery = _IEFormElementGetObjByName($oForm, "q")
_IEFormElementSetValue($oQuery, "AutoIt IE.au3")
_IEFormSubmit($oForm)

If you are worried that the name of the form may change, and you are more confident that the index of the form will remain the same, you can accomplish the same thing using an index instead of a name:

#include <IE.au3>

Local $oIE = _IECreate("http://www.google.com")
Local $oForm = _IEFormGetCollection($oIE, 0)
Local $oQuery = _IEFormElementGetObjByName($oForm, "q")
_IEFormElementSetValue($oQuery, "AutoIt IE.au3")
_IEFormSubmit($oForm)

thanks worked like a charm! I noticed i could also change "q" to "gbqfq", are there any good indicators to use when i look at these webpage sources so i don't make such idiotic mistakes xD?

Share this post


Link to post
Share on other sites

I usually open the site in IE and use the developer tools (F12).

In fact, while you're there, use the icon that looks like a mouse pointer and then you can just click on the element you want to interact with and it will take you to that section of the code.

Share this post


Link to post
Share on other sites

I usually open the site in IE and use the developer tools (F12).

In fact, while you're there, use the icon that looks like a mouse pointer and then you can just click on the element you want to interact with and it will take you to that section of the code.

 Ah I see, thanks a lot.

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

  • Similar Content

    • boy233
      By boy233
      I am working on a form that is dynamic which may appear up to 8 or 15 fields.
      gridText$ct1
      gridText$ct2
      gridText$ct3
      gridText$ct4
      ....
      ....
      ....
      Local $oTextC10 = _IEFormElementGetObjByName($oForm2, "gridText$ct10") $oText10 = _IEFormElementGetValue($oTextC10) I do not want presents this error...
      --> IE.au3 T3.0-1 Warning from function _IEFormElementGetObjByName, $_IESTATUS_NoMatch --> IE.au3 T3.0-1 Error from function _IEFormElementGetValue, $_IESTATUS_InvalidDataType How can I solve this problem?!