Jump to content

Google Search Shortcut


Recommended Posts

Hey all,

I know this code has been attempted before as a GUI app, and it would not copy text properly. Here is an updated version of the Google Search Shortcut  Script from: Google Search Shortcut Script

#include <Clipboard.au3>

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

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

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

While 1

#cs _googleit() Source
User: ViciousXUSMC
#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

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)
            $EncodedString &= '%' & $UnicodeBinaryChar
    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
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

  • Create New...