Sign in to follow this  
Followers 0
Damein

Quick Search!

7 posts in this topic

#1 ·  Posted (edited)

I created this program for another language and decided to re-create it to learn some basics in AutoIt. So, here it is.

You can search from Google, Yahoo!, Bing, YouTube or Lyrics. And you can paste your clipboard straight to the edit box for quick searching from website to website or notepad to websites.

Thanks to Melba for the help.

#include <GUIConstantsEx.au3>

Global $Website

HotKeySet("`", "ShowGUI")

GUICreate("Quick Search", 200, 130)
$WebsiteMenu = GUICtrlCreateMenu("Websites")
$WebsiteItemGoogle = GUICtrlCreateMenuItem("Google", $WebsiteMenu)
$WebsiteItemYahoo = GUICtrlCreateMenuItem("Yahoo!", $WebsiteMenu)
$WebsiteItemBing = GUICtrlCreateMenuItem("Bing", $WebsiteMenu)
$WebsiteItemYouTube = GUICtrlCreateMenuItem("YouTube", $WebsiteMenu)
$WebsiteItemLyrics = GUICtrlCreateMenuItem("Lyrics", $WebsiteMenu)
$hLabel = GUICtrlCreateLabel("You are currently not searching", 0, 0, 200, 20)
$SearchEdit = GUICtrlCreateEdit("", 0, 20, 200, 20)
GUICtrlSetState(-1, $GUI_HIDE) ; Hide this control until we have a website to search
$SearchButton = GUICtrlCreateButton("Submit", 60, 50, 60, 20)
GUICtrlSetState(-1, $GUI_HIDE) ; Hide this control until we have a website to search
$Clipboard = GUICtrlCreateButton("Paste", 60, 80, 60, 20)

$sCurrWebsite = ""

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $WebsiteItemGoogle
            $WebSite = "Google"
        Case $WebsiteItemYahoo
            $WebSite = "Yahoo"
        Case $WebsiteItemBing
            $WebSite = "Bing"
        Case $WebsiteItemYouTube
            $WebSite = "YouTube"
        Case $WebsiteItemLyrics
            $WebSite = "Lyrics"
        Case $SearchButton
            If $WebSite = "Google" Then
            $SearchQuery = ControlGetText("Quick Search", "", "Edit1")
            ShellExecute("http://www.google.ca/search?hl=en&safe=off&q=" & $SearchQuery)
            GUISetState(@SW_HIDE)
        EndIf
            If $WebSite = "Yahoo" Then
            $SearchQuery = ControlGetText("Quick Search", "", "Edit1")
            ShellExecute("http://search.yahoo.com/search;_ylt=Ah1UsM_xzvpK1uhhoabYUSqbvZx4?p=" & $SearchQuery & "&toggle=1&cop=mss&ei=UTF-8&fr=yfp-t-701")
            GUISetState(@SW_HIDE)
        EndIf
            If $WebSite = "Bing" Then
            $SearchQuery = ControlGetText("Quick Search", "", "Edit1")
            ShellExecute("http://www.bing.com/search?q=" & $SearchQuery & "&go=&form=QBLH&scope=web&qs=n&sk=&sc=8-4")
            GUISetState(@SW_HIDE)
        EndIf
            If $WebSite = "YouTube" Then
            $SearchQuery = ControlGetText("Quick Search", "", "Edit1")
            ShellExecute("http://www.youtube.com/results?search_query=" & $SearchQuery & "&aq=f")
            GUISetState(@SW_HIDE)
        EndIf
            If $WebSite = "Lyrics" Then
            $SearchQuery = ControlGetText("Quick Search", "", "Edit1")
            ShellExecute("http://www.lyrics.com/search.php?keyword=" & $SearchQuery & "&what=all&search_btn.x=0&search_btn.y=0")
            GUISetState(@SW_HIDE)
        EndIf
    Case $Clipboard
        $ClipBoardContents = ClipGet()
        ControlSetText("Quick Search", "", "Edit1", $ClipBoardContents)
    EndSwitch

    If $WebSite <> $sCurrWebsite Then ; If we do check then we get flickering as we SHOW the controls on each pass
        GUICtrlSetData($hLabel, "You are currently searching: " & $WebSite) ; This is how you change the text of a control
        GUICtrlSetState($SearchEdit, $GUI_SHOW) ; We have a website, so SHOW the control
        GUICtrlSetState($SearchButton, $GUI_SHOW) ; We have a website, so SHOW the control
        ControlFocus("Quick Search", "", "Edit1")
        $sCurrWebsite = $WebSite
    EndIf
WEnd

    Func ShowGUI()
    GUISetState(@SW_SHOW)
EndFunc
Edited by Damein

MCR.jpg?t=1286371579

Most recent sig. I made

Quick Launcher W/ Profiles Topic Movie Database Topic & Website | LiveStreamer Pro Website | YouTube Stand-Alone Playlist Manager: Topic | Weather Desktop Widget: Topic | Flash Memory Game: Topic | Volume Control With Mouse / iTunes Hotkeys: Topic | Weather program: Topic | Paws & Tales radio drama podcast mini-player: Topic | Quick Math Calculations: Topic

Share this post


Link to post
Share on other sites



It seems a GUISetState() was forget ! Posted Image


AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Share this post


Link to post
Share on other sites

Where? I seem to have no problems with it o_o;


MCR.jpg?t=1286371579

Most recent sig. I made

Quick Launcher W/ Profiles Topic Movie Database Topic & Website | LiveStreamer Pro Website | YouTube Stand-Alone Playlist Manager: Topic | Weather Desktop Widget: Topic | Flash Memory Game: Topic | Volume Control With Mouse / iTunes Hotkeys: Topic | Weather program: Topic | Paws & Tales radio drama podcast mini-player: Topic | Quick Math Calculations: Topic

Share this post


Link to post
Share on other sites

when i start your script nothing happen !

If i add a guisetstate ( ) at the end of creation of the gui, it works...

And what's the utility of $state = 1 ?


AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Share this post


Link to post
Share on other sites

Weird.. I don't have that problem, even when I copy/paste.

And, the $state = 1 was a test I forgot to remove ^^;

Thanks.

Did you press the ` key? Because the reason it doesn't have the show at the creation its suppose to be toggled.

If you did press ` and nothing happened.. then we might have a problem, lol.


MCR.jpg?t=1286371579

Most recent sig. I made

Quick Launcher W/ Profiles Topic Movie Database Topic & Website | LiveStreamer Pro Website | YouTube Stand-Alone Playlist Manager: Topic | Weather Desktop Widget: Topic | Flash Memory Game: Topic | Volume Control With Mouse / iTunes Hotkeys: Topic | Weather program: Topic | Paws & Tales radio drama podcast mini-player: Topic | Quick Math Calculations: Topic

Share this post


Link to post
Share on other sites

Sorry, i didn't see the hotkeyset ! Posted Image


AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Share this post


Link to post
Share on other sites

Haha, no problem! ;)


MCR.jpg?t=1286371579

Most recent sig. I made

Quick Launcher W/ Profiles Topic Movie Database Topic & Website | LiveStreamer Pro Website | YouTube Stand-Alone Playlist Manager: Topic | Weather Desktop Widget: Topic | Flash Memory Game: Topic | Volume Control With Mouse / iTunes Hotkeys: Topic | Weather program: Topic | Paws & Tales radio drama podcast mini-player: Topic | Quick Math Calculations: Topic

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