Sign in to follow this  
Followers 0
sensalim

How to open google and search automatically?

7 posts in this topic

Ok say I have a GUI that has an input box and a go button.

User put "sql tutorial" in the input box and press {ENTER} (or click the go button).

This far I know how to do.

But, how do I open IE (or user's default browser) and it automatically 'googles' "sql tutorial"

displaying the result for the user?

Thanks!

(I tried search but confused on what the keyword should be, found nothing useful so far).

Share this post


Link to post
Share on other sites



Here's a quick example :

#include <GUIConstants.au3>
#Include <IE.au3>

$a = InputBox("Google search","type what you want to search here :")
Preview($a)

Func Preview($Submit = "")
    $oIE = _IECreate ("http://www.google.com")
    $oForm = _IEFormGetObjByName ($oIE, "f")
    $oQuery = _IEFormElementGetObjByName ($oForm, "q")
    _IEFormElementSetValue ($oQuery, $Submit)
    _IEFormSubmit ($oForm)
EndFunc

Hope it helped !

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Yes it works.

Thank you.

Edit:

How about maps.google.com

or what is this thing:

$oForm = _IEFormGetObjByName ($oIE, "f")
$oQuery = _IEFormElementGetObjByName ($oForm, "q")

Edit:

Oh I got it, it's from the page source, <form and stuff

<form action="/search" name=f><table cellpadding=0 cellspacing=0><tr valign=top><td width=25%>&nbsp;</td><td align=center nowrap><input name=hl type=hidden value=en><input maxlength=2048 name=q size=55 title="Google Search" value="">
Edited by sensalim

Share this post


Link to post
Share on other sites

With pleasure :) !

Share this post


Link to post
Share on other sites

You could also go straight to the 1st results page instead of the homepage, but it's good to learn how to use forms via autoit.

#Include <IE.au3>

$a = InputBox("Google search","type what you want to search here :")
GoogleSearch($a)

Func GoogleSearch($strSearch)
    $strSearch = StringReplace($strSearch," ","+")
    $oIE = _IECreate ("http://www.google.com/search?hl=en&q=" & $strSearch)
EndFunc

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Crap, it doesn't work with maps.google.com

... hint?

Edit:

It works with spudw2k's way, though.

Edited by sensalim

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Dang, Googles source is not very reader friendly. :) Try this instead in the meantime.

#Include <IE.au3>
$a = InputBox("Google search","type what you want to search here :")
GoogleSearch($a)

Func GoogleSearch($strSearch)
    $strSearch = StringReplace($strSearch," ","+")
    $oIE = _IECreate ("http://maps.google.com/?ie=UTF8&hl=en&q=" & $strSearch)
EndFunc
Edited by spudw2k

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