Jump to content

search google or wikipedia from clipboard


rx3210
 Share

Recommended Posts

I searched the forum but I couldn't find a relevant topic and I want to be sure if someone already made a script that helps using the clipboard content from any interface to instantly searching google or wikipedia.

example: opening pdf document then highlighting a word then copying it via ctrl+c shortcut and finding results waiting for you to read in the browser from google or wikipedia

 

Link to comment
Share on other sites

?

#include <ie.au3>
Local $sNewContent = ClipGet(), $sLastContent = $sNewContent, $oForm
Local $oIe = _IECreate("https://www.google.com")
Local $hIe = _IEPropertyGet($oIe, "hwnd")

While WinExists($hIe)
    Sleep(500)
    $sNewContent = ClipGet()
    If Not @error Then ; some text was in the ClipBoard
        If $sNewContent <> $sLastContent Then ; the clipboard content has changed
            $sLastContent = $sNewContent
            _IENavigate($oIe, "https://www.google.com/?q=" & ClipGet())
            $oForm = _IEFormGetCollection($oIe, 0)
            _IEFormSubmit($oForm)
        EndIf
    EndIf
WEnd

 

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Link to comment
Share on other sites

Thank you very much Reverend Chimp. we are almost there and my apology for leeching on your great mind, 

How can I make it work for multiple sites where each site shows result in its own tab and the multiple tabs merged in one window? The tricky thing is to use the same tabs upon highlighting new %text% to avoid opening numerous tabs which make the browser lag.

I am trying to get these sites below working, and my default browser is firefox.

http://en.wikipedia.org/wiki/Special:Search?search=%text%
https://www.google.ch/?gfe_rd=cr&ei=uUp5VoD9DuqX8QfG9qG4Cg#safe=off&q=define:%text%
http://search.medscape.com/search/?q=%text%&plr=ref&page=1
http://www.drugs.com/search.php?searchterm=%text%
http://www.drugs.com/search.php?sources[]=condition&searchterm=%text%
http://google2.fda.gov/search?q=%text%&client=FDAgov&proxystylesheet=FDAgov&output=xml_no_dtd&site=FDAgov-Section-Drugs&requiredfields=-archive:Yes&filter=0
http://www.mayomedicallaboratories.com/test-catalog/alphabetical/%text%
http://www.mayomedicallaboratories.com/test-catalog/diseases/%text%
http://ar.wikipedia.org/wiki/Special:Search?search=%text%
http://www.mayoclinic.org/search/search-results?q=%text%&site=site-search

 

Link to comment
Share on other sites

Reverend ?? ..... :D

... maybe something like this:

#include <GUIConstantsEx.au3>
#include <IE.au3>
Local $aoIE[11] ; 1 to 10 will be used
Global $aURL[11]
Local $sNewContent = ClipGet(), $sLastContent = $sNewContent, $nMsg
HotKeySet("{Esc}", "_End")

Global $hGui = GUICreate("Multi search", 1000, 520, (@DesktopWidth - 1000) / 2, (@DesktopHeight - 520) / 2)

GUICtrlCreateTab(0, 0, 1000, 520)
For $i = 1 To UBound($aoIE) - 1
    $aoIE[$i] = _IECreateEmbedded() ; Create instance of browser
    GUICtrlCreateTabItem("Search results #" & $i) ; Create a TabItem
    GUICtrlCreateObj($aoIE[$i], 00, 20, 1000, 500) ; place the browser on the TabItem
Next
GUICtrlCreateTabItem("") ; End of TabItems
GUISetState(@SW_SHOW)

Do
    ; Sleep(500)
    $sNewContent = ClipGet()
    If Not @error And $sNewContent <> $sLastContent Then ; there is new text in the ClipBoard
        $sLastContent = $sNewContent
        _UrlMaker($sNewContent)
        For $i = 1 To UBound($aoIE) - 1
            _IENavigate($aoIE[$i], $aURL[$i], 0)
        Next
    EndIf
Until GUIGetMsg() = $GUI_EVENT_CLOSE

Func _UrlMaker($sText)
    $aURL[1] = 'http://en.wikipedia.org/wiki/Special:Search?search=' & $sText
    ; $aURL[2] = 'https://www.google.ch/?gfe_rd=cr&ei=uUp5VoD9DuqX8QfG9qG4Cg&safe=off&q=define:' & $sText
    $aURL[2] = 'https://www.google.ch/?gfe_rd=cr&ei=uUp5VoD9DuqX8QfG9qG4Cg&gws_rd=cr,ssl#q=' & $sText
    $aURL[3] = 'http://search.medscape.com/search/?q=' & $sText & '&plr=ref&page=1'
    $aURL[4] = 'http://www.drugs.com/search.php?searchterm=' & $sText
    $aURL[5] = 'http://www.drugs.com/search.php?sources[]=condition&searchterm=' & $sText
    $aURL[6] = 'http://google2.fda.gov/search?q=' & $sText & '&client=FDAgov&proxystylesheet=FDAgov&output=xml_no_dtd&site=FDAgov-Section-Drugs&requiredfields=-archive:Yes&filter=0'
    $aURL[7] = 'http://www.mayomedicallaboratories.com/test-catalog/alphabetical/' & $sText
    $aURL[8] = 'http://www.mayomedicallaboratories.com/test-catalog/diseases/' & $sText
    $aURL[9] = 'http://ar.wikipedia.org/wiki/Special:Search?search=' & $sText
    $aURL[10] = 'http://www.mayoclinic.org/search/search-results?q=' & $sText & '&site=site-search'
EndFunc   ;==>_UrlMaker

Func _End()
    If WinActive($hGui) Then
        GUIDelete($hGui)
        Exit
    EndIf
EndFunc   ;==>_End

a little lag occurs during the update of the 10 pages.

Edited by Chimp

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Link to comment
Share on other sites

Your code is an awesome Christmas gift.  I managed to add one extra link (tab) successfully, but I was wondering how to name each tab to differentiate it from the rest? The window result can't be maximized to full screen but I changed the numbers and now it fits my screen.

Edited by rx3210
Link to comment
Share on other sites

I'm glad this simple script can be of use for you...
Here a little modification that allows you to change the titles of the tabs, just set what you like in the $aTabTitles array.
also you can change the $iWinWidth and $iWinHeight variables to set window dimension as you prefer.
... happy holidays :)

#include <GUIConstantsEx.au3>
#include <IE.au3>
Local $iTabs = 10 ;                             <--- number of wanted tabs (and urls)
; Local $iWinWidth = 1150, $iWinHeight  = 550 ; <--- change window dimensions here
Local $iWinWidth = @DesktopWidth, $iWinHeight  = @DesktopHeight ; <--- or use this to set window to full screen
Local $aoIE[$iTabs + 1] ; 1 based arrays
Global $aURL[$iTabs + 1]
Local $aTabTitles[$iTabs + 1] = ['', _ ; index 0 unused
        'en.wikipedia.org', _ ;    tab 1
        'www.google.ch', _ ;       tab 2
        'search.medscape.com', _ ; tab 3
        'www.drugs.com', _ ;       tab 4
        'www.drugs.com', _ ;       tab 5
        'google2.fda.gov', _ ;     tab 6
        'mayomedicallaboratories alphabetical', _ ; tab 7
        'mayomedicallaboratories diseases', _ ;     tab 8
        'ar.wikipedia.org', _ ;    tab 9
        'www.mayoclinic.org'] ;    tab 10 ..... etc

Local $sNewContent = ClipGet(), $sLastContent = $sNewContent
HotKeySet("{Esc}", "_End")

Global $hGui = GUICreate("Multi search", $iWinWidth, $iWinHeight, (@DesktopWidth - $iWinWidth) / 2, (@DesktopHeight - $iWinHeight) / 2)

GUICtrlCreateTab(0, 0, $iWinWidth, $iWinHeight)
For $i = 1 To UBound($aoIE) - 1
    $aoIE[$i] = _IECreateEmbedded() ; Create instance of browser
    GUICtrlCreateTabItem($aTabTitles[$i]) ; Create a TabItem
    GUICtrlCreateObj($aoIE[$i], 00, 20, $iWinWidth, $iWinHeight - 20) ; place the browser on the TabItem
Next
GUICtrlCreateTabItem("") ; End of TabItems
GUISetState(@SW_SHOW)

Do
    ; Sleep(500)
    $sNewContent = ClipGet()
    If Not @error And $sNewContent <> $sLastContent Then ; there is new text in the ClipBoard
        $sLastContent = $sNewContent
        _UrlMaker($sNewContent)
        For $i = 1 To UBound($aoIE) - 1
            _IENavigate($aoIE[$i], $aURL[$i], 0)
        Next
    EndIf
Until GUIGetMsg() = $GUI_EVENT_CLOSE

Func _UrlMaker($sText)
    $aURL[1] = 'http://en.wikipedia.org/wiki/Special:Search?search=' & $sText
    ; $aURL[2] = 'https://www.google.ch/?gfe_rd=cr&ei=uUp5VoD9DuqX8QfG9qG4Cg&safe=off&q=define:' & $sText
    $aURL[2] = 'https://www.google.ch/?gfe_rd=cr&ei=uUp5VoD9DuqX8QfG9qG4Cg&gws_rd=cr,ssl#q=' & $sText
    $aURL[3] = 'http://search.medscape.com/search/?q=' & $sText & '&plr=ref&page=1'
    $aURL[4] = 'http://www.drugs.com/search.php?searchterm=' & $sText
    $aURL[5] = 'http://www.drugs.com/search.php?sources[]=condition&searchterm=' & $sText
    $aURL[6] = 'http://google2.fda.gov/search?q=' & $sText & '&client=FDAgov&proxystylesheet=FDAgov&output=xml_no_dtd&site=FDAgov-Section-Drugs&requiredfields=-archive:Yes&filter=0'
    $aURL[7] = 'http://www.mayomedicallaboratories.com/test-catalog/alphabetical/' & $sText
    $aURL[8] = 'http://www.mayomedicallaboratories.com/test-catalog/diseases/' & $sText
    $aURL[9] = 'http://ar.wikipedia.org/wiki/Special:Search?search=' & $sText
    $aURL[10] = 'http://www.mayoclinic.org/search/search-results?q=' & $sText & '&site=site-search'
EndFunc   ;==>_UrlMaker

Func _End()
    If WinActive($hGui) Then
        GUIDelete($hGui)
        Exit
    EndIf
EndFunc   ;==>_End

 

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

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