Jump to content

Internet Explorer Google Search Example Help Please


Recommended Posts

Hi there,

I'm trying to learn AutoIT and attempting to cut my teeth on some of the examples. I've tried a few examples and I'm getting errors on almost all of them relating to Internet Explorer scripts.

For example, the script "Send search to Google":

#include <IE.au3>

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

I get the following error message (and I ran it both in beta mode and normal).

--> 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

+>23:52:34 AutoIT3.exe ended.rc:0

Since this was a copy/paste from the example code, I'm struggling to see what I'm doing wrong?

Any help GLADLY received.

Thanks

Link to comment
Share on other sites

for me that script work correctly. which autoit version do you use?

also you can use ShellExecute to open a web page.

shellexecute("www.google.com.uk")
Link to comment
Share on other sites

Google changed the name of the search form from "f" to "gbqf". Change that in the script and it should work.

This is one of the only examples I included that relied on an external webpage. Please don't make a comment like "I've tried a few examples and I'm getting errors on almost all of them" without pointing them out so that they can be corrected, if there is a problem with them.

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

Link to comment
Share on other sites

Hi there,

Thank you so much for the replies. Dale, your suggestion fixed things for me.

With reference to the other examples, I should apologise I was using the examples that were listed on the function pages for the Internet Explorer functions and they were all giving the same errors, as listed above. InvalidDatatye and another (cannot remember the error verbatim because it no longer causes an error) and something about an object not being set?

Anyway I think a restart of my pc after installing the latest Beta fixed things (I placed the v3395 folder into the AutoIT folder and renamed it Beta).

Thanks again for your help.

Link to comment
Share on other sites

if you are only concerned with

Google Search

then this works for me in India

#include <IE.au3>
Local $nSearchTerm='Autoit'
$oIE = _IECreate("http://www.google.co.in/webhp#hl=en&sclient=psy-ab&q="&$nSearchTerm)
;Do rest of the Stuff
Edited by PhoenixXL

My code:

PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.

Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners.

MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. 

Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.

Link to comment
Share on other sites

The best way to do Google search or any search is by catching the Text box when u type and then writing into it.. this is the best way and what industries follows. Below is the Code

#include 
$oIE=_IECreate("www.google.com",0, 1, 1, 1)
_IELoadWait($oIE)
$oSb = _IEGetObjByName($oIE, "q") ;here q is the text box name properity so i am grabing it by its name to variable oSb
_IEFormElementSetValue($oSb, "apple") ;here i am sending apple to the variable oSb which is the TEXT box.
sleep(5000)

Aki2

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