AutoIt Forums: How to open google and search automatically? - AutoIt Forums

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

How to open google and search automatically?

#1 User is offline   sensalim 

  • Spammer!
  • PipPipPip
  • Group: Full Members
  • Posts: 228
  • Joined: 19-April 07

Posted 07 April 2008 - 05:26 PM

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

#2 User is offline   LIMITER 

  • LMP Developer
  • PipPipPipPip
  • Group: Full Members
  • Posts: 482
  • Joined: 28-December 07
  • Location:Romania

Posted 07 April 2008 - 05:29 PM

Here's a quick example :

[ code='text' ]    ( Popup )
#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 !
0

#3 User is offline   sensalim 

  • Spammer!
  • PipPipPip
  • Group: Full Members
  • Posts: 228
  • Joined: 19-April 07

Posted 07 April 2008 - 05:32 PM

Yes it works.
Thank you.

Edit:
How about maps.google.com
or what is this thing:

[ code='text' ]    ( Popup )
$oForm = _IEFormGetObjByName ($oIE, "f") $oQuery = _IEFormElementGetObjByName ($oForm, "q")


Edit:
Oh I got it, it's from the page source, <form and stuff
[ code='text' ]    ( Popup )
<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="">

This post has been edited by sensalim: 07 April 2008 - 06:40 PM

0

#4 User is offline   LIMITER 

  • LMP Developer
  • PipPipPipPip
  • Group: Full Members
  • Posts: 482
  • Joined: 28-December 07
  • Location:Romania

Posted 07 April 2008 - 05:34 PM

With pleasure :) !
0

#5 User is online   spudw2k 

  • i dunno what i'm doing
  • PipPipPipPipPip
  • Group: Full Members
  • Posts: 678
  • Joined: 16-August 07
  • Gender:Male
  • Location:CA

Posted 07 April 2008 - 05:41 PM

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.

[ autoIt ]    ( Popup )
#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

0

#6 User is offline   sensalim 

  • Spammer!
  • PipPipPip
  • Group: Full Members
  • Posts: 228
  • Joined: 19-April 07

Posted 07 April 2008 - 06:58 PM

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

Edit:
It works with spudw2k's way, though.

This post has been edited by sensalim: 07 April 2008 - 07:03 PM

0

#7 User is online   spudw2k 

  • i dunno what i'm doing
  • PipPipPipPipPip
  • Group: Full Members
  • Posts: 678
  • Joined: 16-August 07
  • Gender:Male
  • Location:CA

Posted 07 April 2008 - 09:56 PM

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

[ autoIt ]    ( Popup )
#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

This post has been edited by spudw2k: 07 April 2008 - 09:58 PM

0

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users