Jump to content

Simple google searcher


Calster
 Share

Recommended Posts

This script with a GUI will search google for whatever you want i have even included "Im Feeling Lucky" funtionality.

Dont Flame me please this is one of my first projects.

CODE
#include <IE.au3>

#include <GUICONSTANTS.au3>

GUICreate("Search Google",300,145)

GUISetState()

$SearchBox = GUICtrlCreateInput("",0,100,300)

$logo = GUICtrlCreatePic(@DesktopDir & "\logo.gif",0,0,300,100)

$SearchButton = GUICtrlCreateButton("Google Search",0,120,150)

$SearchButton2 = GUICtrlCreateButton("Im Feeling Lucky",150,120,150)

Func Search1($SearchData)

ShellExecute ("iexplore.exe", "about:blank")

WinWait ("Blank Page")

$oIE = _IEAttach ("about:blank", "url")

_IELoadWait ($oIE)

_IENavigate ($oIE, "http://www.google.co.uk/search?hl=en&q=" & $SearchData &"&meta=")

EndFunc

Func Search2($SearchData)

ShellExecute ("iexplore.exe", "about:blank")

WinWait ("Blank Page")

$oIE = _IEAttach ("about:blank", "url")

_IELoadWait ($oIE)

_IENavigate ($oIE, "www.google.com")

$oForm = _IEFormGetObjByName($oIE,"f")

$oSearch = _IEFormElementGetObjByName($oForm,"q")

_IEFormElementSetValue($oSearch,$SearchData)

$oSearchBut2 = _IEFormElementGetObjByName($oForm,"btnI")

_IEAction($oSearchBut2,"click")

EndFunc

While 1

$msg = GUIGetMsg()

Select

Case $msg = $GUI_EVENT_CLOSE

Exit

Case $msg = $SearchButton

Search1(GUICtrlRead($SearchBox))

Case $msg = $SearchButton2

Search2(GUICtrlRead($SearchBox))

EndSelect

WEnd

SSBot.au3

post-28387-1216303368_thumb.gif

Calster - User and lover of AutoIt !

Link to comment
Share on other sites

Here is another one that you might want to check but it doesn't have the I'm Feeling Lucky option.

Opt ("GUICoordMode"," 2")

$Frm_1 = GUICreate("Google Search", 280, 60)
$In = GUICtrlCreateInput("", 5,5,270,20)
$Btn_Search = GUICtrlCreateButton("Search", -165, 5, 60, 25, 1)

GUISetState()
While 1
   $Msg = GuiGetMsg()
   Switch $Msg
      Case - 3
         Exit
      Case $Btn_Search
         $http = "Http://www.google.com/search?hl=en&q=" & StringReplace(GUICtrlRead($In), Chr(32), "+")
         $Http = StringReplace($Http, Chr(34), "%22")
         ShellExecute($Http)
         Exit
   EndSwitch
Wend

I used to keep it on my desktop all the time. Now I have another app that is running all the time which will search Google, MSDN and TechNet so I don't use this one now.

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

Here is another one... muttley

#include <GUIConstants.au3>

$Window = GUICreate("Google Search", 381, 55, 193, 115)
$Label = GUICtrlCreateLabel("Search:", 8, 8, 41, 17)
$Input = GUICtrlCreateInput("", 56, 8, 217, 21)
$Go = GUICtrlCreateButton("Go!", 280, 8, 89, 25, 0)
$clearwebsearch = GUICtrlCreateButton ("Clear", 250, 32, 60, 20)
GUISetState(@SW_SHOW)

While 1
 If GUICtrlRead($Input) = "" Then
  If GUICtrlGetState($Label) = 80 Then GUICtrlSetState($Label, 144)
  If GUICtrlGetState($Go) = 80 Then GUICtrlSetState($Go, 144)
  If GUICtrlGetState($clearwebsearch) = 80 Then GUICtrlSetState($clearwebsearch, 144)
Else
  If GUICtrlGetState($Label) > 80 Then GUICtrlSetState($Label, 80)
  If GUICtrlGetState($Go) > 80 Then GUICtrlSetState($Go, 80)
  If GUICtrlGetState($clearwebsearch) > 80 Then GUICtrlSetState($clearwebsearch, 80)
Endif
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
  case $clearwebsearch
  GUICtrlSetData($Input,"")    
        Case $Go
            ShellExecute("[url="http://www.google.com/search?q"]www.google.com/search?q[/url]=" & GUICtrlRead($Input))
    EndSwitch
WEnd
Link to comment
Share on other sites

Here is another one... muttley

<snipped>

I've had problems with not replacing spaces with + Edited by GEOSoft

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

I could see that possibly causing a problem.. I was mainly showing the dissable part.. You can just change the orig code with this for a neat effect

While 1
If GUICtrlRead($SearchBox) = "" Then
  If GUICtrlGetState($SearchButton) = 80 Then GUICtrlSetState($SearchButton, 144)
  If GUICtrlGetState($SearchButton2) = 80 Then GUICtrlSetState($SearchButton2, 144)

Else
  If GUICtrlGetState($SearchButton) > 80 Then GUICtrlSetState($SearchButton, 80)
  If GUICtrlGetState($SearchButton2) > 80 Then GUICtrlSetState($SearchButton2, 80)
Endif
 $msg = GUIGetMsg()
 Select
 Case $msg = $GUI_EVENT_CLOSE
  Exit
 Case $msg = $SearchButton
  Search1(GUICtrlRead($SearchBox))
 Case $msg = $SearchButton2
  Search2(GUICtrlRead($SearchBox))
 EndSelect
WEnd
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...