0
votes

I am using FastestFox for firefox and nice feature of his is that it shows you a gui with corresponding links to imdb, wikipedia etc, after selecting some text.

Is there a script or can i modify this script http://www.autohotkey.com/board/topic/53057-quick-google-images-dictionary-ahk-and-wikipedia-search/ to show her gui after selecting text. My goal is to show the gui without having to hit keyboard combination.

Thanks.

1
Don't try to do that with AHK...it is at most nearly impossible. For browsers, you can use JavaScript (e.g. Userscripts) to achieve that. Here's an example.MCL
Aha, i thought that was possible with ahk, thanks anywayVe-Khan
So, do you want to use it only in browsers or in other programs, too?MCL
In other programs too, my intention wasVe-Khan

1 Answers

0
votes

Although JavaScript would be a much better choice for browsers, here's an example script that can do what you want.

SendMode, Input

~LButton UP::
    clipTmp := ClipboardAll
    Clipboard := ""
    Send, ^c
    ClipWait, 1
    if(ErrorLevel) { ; No text selected
        GoSub, RestoreClip
        return
    }
    selectedText := Clipboard
    GoSub, RestoreClip
    TrayTip, Text selected!, % selectedText
return

RestoreClip:
    Clipboard := clipTmp
    clipTmp := ""
return

This is a very basic template that you'll have to adjust to your needs. For example, it won't work correctly when you're selecting a word by double clicking. Also, it "locks" the clipboard for one second after a click (no matter what), so that copying/pasting won't have effect within that time span. All these problems are bypassable, but I'll leave that up to you.
Moreover, be aware that this code relies on the target window to copy the selected text into the clipboard after CTRL + C has been sent to it; and this must happen faster than whatever timeout you pass to ClipWait.