Jump to content

Google Search Shortcut Script


BlueRabbit
 Share

Recommended Posts

By the way I think you could make money with a professional software that simply manages different search engines and assigned hotkeys. Exactly what my scipt above does plus user friendly management for several different search engines and hotkeys. And of course installation script :)

There is a similiar software called "click.to", which does the very same thing, but instead of a hotkey, you have to press a button of an appearing sidebar, which is not as quick as a hotkey.

Link to comment
Share on other sites

Just for funzies, looks like Ctrl+Escape is not working as a hotkey but everything else is working.

Not sure if there was a better way to handle my checkboxes, but this solution worked well enough.

You can run multiple instances of this each with a different hotkey and search provider.  Im sure if you look it over that it would be easy to add more searches as desired.

Personally I only use google for everything lol

#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=C:\Users\it022565\Desktop\Search Current\Form1.kxf
$Form1 = GUICreate("Form1", 498, 190, 192, 124)
$Combo1 = GUICtrlCreateCombo("Hotkey", 96, 56, 145, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GUICtrlSetData(-1, "{F1}|{F2}|{F3}|{F4}|{F5}|{F6}|{F7}|{F8}|{F9}|{F10}|{F11}|{F12}")
$Checkbox1 = GUICtrlCreateCheckbox("Shift", 24, 40, 57, 17)
$Checkbox2 = GUICtrlCreateCheckbox("Control", 24, 56, 65, 17)
$Checkbox3 = GUICtrlCreateCheckbox("Alt", 24, 72, 49, 17)
$Combo2 = GUICtrlCreateCombo("Search Site", 304, 56, 169, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GUICtrlSetData(-1, "Google.com|Google.at")
$Checkbox4 = GUICtrlCreateCheckbox("Shift", 24, 120, 49, 17)
$Checkbox5 = GUICtrlCreateCheckbox("Control", 24, 136, 65, 17)
$Checkbox6 = GUICtrlCreateCheckbox("Alt", 24, 152, 41, 17)
$Input1 = GUICtrlCreateInput("Input1", 96, 128, 145, 21)
GUICtrlSetData(-1, "{ESC}")
$Button1 = GUICtrlCreateButton("GO!", 328, 120, 123, 41)
$Label1 = GUICtrlCreateLabel("Hotkey To Open Search", 80, 16, 120, 17)
$Label2 = GUICtrlCreateLabel("Where To Perform Search", 328, 16, 128, 17)
$Label3 = GUICtrlCreateLabel("Hotkey To Exit", 88, 96, 74, 17)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            ExitLoop
    EndSwitch
WEnd

Global $sOldClip

$vTerminate = ''
If GUICtrlRead($Checkbox4) = $GUI_CHECKED Then $vTerminate &= "+"
If GUICtrlRead($Checkbox5) = $GUI_CHECKED Then $vTerminate &= "^"
If GUICtrlRead($Checkbox6) = $GUI_CHECKED Then $vTerminate &= "!"
$vTerminate &= GUICtrlRead($Input1)

$vSearch = ''
If GUICtrlRead($Checkbox1) = $GUI_CHECKED Then $vSearch &= "+"
If GUICtrlRead($Checkbox2) = $GUI_CHECKED Then $vSearch &= "^"
If GUICtrlRead($Checkbox3) = $GUI_CHECKED Then $vSearch &= "!"
$vSearch &= GUICtrlRead($Combo1)

Switch GuiCtrlRead($Combo2)
    Case "Google.com"
        $sSearch = "https://www.google.com/search?q="
    Case "Google.at"
        $sSearch = "https://www.google.at/search?q="
    Case Else
        $sSearch = GUICtrlRead($Combo2)
EndSwitch

HotKeySet($vTerminate, "Terminate")
HotKeySet($vSearch, "MySearch")

GUIDelete($Form1)

While 1
    Sleep(10)
WEnd

Func MySearch()
$sOldClip = ClipGet()
Send("^c")
ShellExecute($sSearch & ClipGet())
ClipPut($sOldClip)
EndFunc

Func Terminate()
    Exit
EndFunc

 

Link to comment
Share on other sites

haha nice!

As I said, I personally prefer not having a script running in background if not necessary so I am very fine with my solution. But your GUI is nice! :)

Make an installer and sell it - I wanna have 90 % for my idea haha ;)

Edited by BlueRabbit
Link to comment
Share on other sites

  • 3 years later...

Hey everybody,

Personally, I prefer a non-GUI for this type of program. Here is an update to BlueRabbit's Google Search Hotkey.  I also fixed a bug in ViciousXUSMC's example (it wouldn't copy from notepad because it would lose focus of the window before switching to Chrome)

#Region
#AutoIt3Wrapper_Outfile=shortcuts.exe
#EndRegion
#include <Clipboard.au3>

Opt("TrayMenuMode", 3)
Opt("TrayOnEventMode", 1)

HotKeySet("{F1}", "_googleit")

TraySetToolTip("Right click to exit")
TrayCreateItem("Exit")
TrayItemSetOnEvent(-1, "_exit")

While 1
    Sleep(20)
WEnd

#cs _googleit() Source
User: ViciousXUSMC
https://www.autoitscript.com/forum/topic/177446-google-search-shortcut-script/?do=findComment&comment=1273519
#ce Source

Func _googleit()
    Opt("WinTitleMatchMode", 2) ;Set Title Match To "Any Part of String"
    $sOldClip = ClipGet() ;Save Current Clipboard
    Send("^c") ;Copy Selected Text to Clipboard *before losing focus of current window
    WinActivate("Google Chrome", "") ; activate chrome
    ShellExecute("https://www.google.at/search?q=" & URLEncode(_ClipBoard_GetData())) ;Navigate to search
    ClipPut($sOldClip) ;Restore Old Clipboard
    Opt("WinTitleMatchMode", 1) ; Sets back to default
EndFunc   ;==>_googleit


;URL encoding is critical when doing string search queries via URL.

#cs URLEncode Source
User: Dhilip89 - UnicodeURL UDF
https://www.autoitscript.com/forum/topic/46894-unicodeurl-udf/
#ce

Func URLEncode($UnicodeURL)
    $UnicodeBinary = StringToBinary($UnicodeURL, 4)
    $UnicodeBinary2 = StringReplace($UnicodeBinary, '0x', '', 1)
    $UnicodeBinaryLength = StringLen($UnicodeBinary2)
    Local $EncodedString
    For $i = 1 To $UnicodeBinaryLength Step 2
        $UnicodeBinaryChar = StringMid($UnicodeBinary2, $i, 2)
        If StringInStr("$-_.+!*'(),;/?:@=&abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890", BinaryToString('0x' & $UnicodeBinaryChar, 4)) Then
            $EncodedString &= BinaryToString('0x' & $UnicodeBinaryChar)
        Else
            $EncodedString &= '%' & $UnicodeBinaryChar
        EndIf
    Next
    Return $EncodedString
EndFunc   ;==>URLEncode

Func _exit()
    $result = MsgBox(1, "Shortcuts", "Do you wish to exit Shortcuts?", 0)
    If $result == 1 Then Exit
EndFunc   ;==>_exit

 

 

Edited by mannworks00
Forum rules, I must create a new thread when replying to old threads.
Link to comment
Share on other sites

Thanks, mannworks, looks pretty complicated. I am already running the following script very successfull for some years: (background-mode makes indeed more sense)

HotKeySet("{F9}", "GoogleSearch")
HotKeySet("{F10}", "DictSearch")
HotKeySet("{F11}", "InsertActDate")

While 1
   Sleep(10)
WEnd

Func GoogleSearch()
   Send("^c")
   Sleep(80)
   ShellExecute("https://www.google.com/search?q=" & ClipGet())
EndFunc

Func DictSearch()
   Send("^c")
   Sleep(80)
   ShellExecute("https://www.dict.cc/?s=" & ClipGet())
EndFunc

Func InsertActDate()
   $date = @YEAR & "-" & @MON & "-" & @MDAY
   Send($date)
EndFunc

 

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