Jump to content

Go to solution Solved by DW1,

Recommended Posts

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?
Link to comment
Share on other sites

  • Solution

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
Link to comment
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?

Link to comment
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.

Link to comment
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.

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

×
×
  • Create New...