!google (from clipboard) Thread last updated on 2008-05-22 23:20:31

Posted by member 316614 on 2006-09-09 10:33:36

ok, I wanted to write a short script which googles a word or phrase I copied. So I would copy followed by a hotkey or button to search google (or wiki, or whatever).

Seems easy enough:

*script bang !google
*script exec !textappend @c:\\temporary.rc@ @evar \c@
*script exec !mzLoadVarFile c:\temporary.rc
*script exec !command ? %{evar:line}
*script exec !textdel @c:\\temporary.rc@ @.@
*script ~bang

...and works well so far, but somehow it always delets or alters the last letter of the copied text. Any idea how I have to change the syntax around '\c@ to remedy that?

Posted by member 316614 on 2006-09-09 11:27:22 link

edit* argh, no that didn't work either. It's truly mysterious; if the word ends in a 'g' it either changes that to 'c' or 'e', other letters mostly get swallwed.

edit** damn you \c, damn you to hell. This would have been quite useful to me. Well, maybe the problem arises for my machine only, so if you like, try the code out (with mzscript 1.0, lsxcommand 1.9.4 and textedit 2.5).

Posted by member 212670 on 2006-09-09 15:47:20 link

Or you could simply do:

*Hotkey CTRL G !ParseEvars !command ?google %[clipboardText]%

Only requires xlabel and lsxcommand be loaded.

1. Copy to clipboard. (ctrl + c)
2. Press hotkey. (ctrl + g)

edit -

Is there a Litestep module that will send key presses? I thought there was one, but I can't find it. With that, you could just have the hotkey line !execute the copy/!command, making the above just one step. I can't see a way without using an external program.

Posted by member 316614 on 2006-09-09 16:46:25 link

Thanks, that worked beautifully. Really should have looked into xlabel's possibillities.

"Is there a Litestep module that will send key presses?"
I have been searching for one too as I imagine it could be usefull for a lot of applications, but so far found none.

Posted by member 5575 on 2006-09-09 19:43:50 link

bptypein.dll, IIRC.

Posted by member 212670 on 2006-09-09 22:13:38 link

Ahh good call Brian, that's the one.

Ok, here it is revised:

Load bptypein (packaged as typein-991019).

*Hotkey CTRL G !googleit

*Script bang !googleit
*Script exec !TypeIn "^C" ;hold ctrl
*Script exec !TypeIn "^_C" ;press C in WM_KEYDOWN mode
*Script exec !TypeIn "^C" ;release ctrl
*Script exec !pause 250 ;script was too fast for the clipboard
*Script exec !ParseEvars !command ?google %[clipboardText]%
*Script ~bang


Then, just ctrl+g for auto googling highlighted text.

That can be laid out in one !execute, but you still need the !pause. If you're already using mzscript, you may aswell use the !pause built into it, and layout it as a script.

Posted by member 5575 on 2006-09-09 22:35:32 link

Ya know, in Firefox I can just hilight text and right click on it, then select "Search web for [whatever it was]", which will perform a google search. That only works within the browser though, so this script is more general.

Posted by member 212670 on 2006-09-09 23:45:18 link

Ya, it's a 'for everything' kinda script. In Firefox, I just drag and drop text to the search box. Didn't know about the right click on text thing (I usually am using hotkeys). That's pretty cool, too. Opens a new tab and all.

Posted by member 5575 on 2006-09-10 00:07:04 link

Heh - *I* never tried drag'n drop of text in the search box before. Yet another neat trick.

Posted by member 248213 on 2006-09-10 02:31:53 link

Now you just need to bind that to the huge "GOOGLE" button on our keyboard! XD Cool idea

Posted by member 378340 on 2008-05-22 23:20:31 link

some keyboards have "special" buttons, you could write "google" on one of them and assign the hotkey to it :). not sure how though...

or just "G", either way awsome idea.