Jump to content

How to open google and search automatically?


Recommended Posts

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

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

Link to comment
Share on other sites

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

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