Nahuel Posted August 24, 2007 Share Posted August 24, 2007 Basically, what this script does is check every half a second if there's text in the clipboard. If there is, it searches for definitions using _Define() (By AzKay). Select the word you want the definition for and press TAB.It works alright, except that it won't let me use the clipboard or the tab key while it's running. I was wondering if there was some way to get selected text. Or read a word by hovering the mouse over it... Something like that, so I can use the clipboard while the script is running...expandcollapse popup#include <Array.au3> ClipPut("") HotKeySet("{tab}","copy") AdlibEnable("word_clip",500) While 1 Sleep(100) WEnd Func word_clip() If ClipGet()="" Then Else $oWord = _Define(Clipget()) UBound($oWord) if @error <> 1 Then For $i=1 To $oWord[0] MsgBox(0,"Definition for "&Clipget() , $oWord[$i]) Next ClipPut("") Else MsgBox(0,"","No definitions were found for "&Clipget()) ClipPut("") EndIf EndIf EndFunc Func copy() Send("^c") EndFunc Func _Define($oWord) Local $oWordx $oHTTP = ObjCreate("Microsoft.XMLHTTP") $oHTTP.Open("GET", "http://www.google.com/search?hl=es&rls=IRFA%2CIRFA%3A2007-32%2CIRFA%3Aen&q=define%3A"& $oWord&"&lr=" , False) $oHTTP.Send() $oWords = StringRegExp($oHTTP.ResponseText, "<font size=-1><li>(.*?)<br>", 3) For $i = 0 To UBound($oWords) -1 $oWordx = $oWordx & $oWords[$i] & "#" Next $oWordx = StringTrimRight($oWordx, 1) $oWordx = StringReplace($oWordx, "'", "'") $oWordx = StringReplace($oWordx, "&", "&") $oWordx = StringReplace($oWordx, "<li>", "") $oWordx = StringReplace($oWordx, """, '"') $oWordx = StringReplace($oWordx, ">", ">") $oWordx = StringReplace($oWordx, "<", "<") $oWordx = StringReplace($oWordx, "", "-") If $oWordx <> "" Then $oWordx = StringSplit($oWordx, "#") Return $oWordx Else SetError(1) Return -1 EndIf EndFunc Link to comment Share on other sites More sharing options...
sandman Posted August 24, 2007 Share Posted August 24, 2007 (edited) I don't see any problem, although for consistency in the function insert something like this:Global $clip = ClipGet()oÝ÷ Ù8^·z·§qëh¶¶èºhºØ[(Ê©àyÛay@Å~º&¶°k 3)¬©¢Ë^v+b¶Z(Ébëaz̧µ¬`zÛ&zËvê[yÆ®±ì¨¹ÈZÒn²Ù^j÷å«!z¯z+m£*.!ûa¢Ç°¢¹2¢éÉ·¾x zÛb°^ì,¢[ÛØý²&¡×^vØ^±Êâ¦×è¯*.N¼+(ºÖ®¶sb6æ6ÇVFRfÇC´'&æS2fwC°¤6ÆWBgV÷C²gV÷C²¤÷D¶W6WBgV÷C··F'ÒgV÷C²ÂgV÷C¶6÷gV÷C² ¤FÆ$Væ&ÆRgV÷C·v÷&Eö6ÆgV÷C²ÃS ¥vÆR¢6ÆVW¥tVæ@ ¤gVæ2v÷&Eö6Æ vÆö&Âb33c¶6ÆÒ6ÆvWB¢bæ÷B6ÆvWBÒgV÷C²gV÷C²FVà¢b33c¶õv÷&BÒôFVfæRb33c¶6Æ¢T&÷VæBb33c¶õv÷&B¢bW'&÷"fÇC²fwC²FVà¢f÷"b33c¶ÓFòb33c¶õv÷&E³Ð¢×6t&÷ÂgV÷C´FVfæFöâf÷"gV÷C²fײb33c¶6ÆÂb33c¶õv÷&E²b33c¶Ò¢æW@¢6ÆWBgV÷C²gV÷C²¢VÇ6P¢×6t&÷ÂgV÷C²gV÷C²ÂgV÷C´æòFVfæFöç2vW&Rf÷VæBf÷"gV÷C²fײb33c¶6Æ¢6ÆWBgV÷C²gV÷C²¢VæD`¢¢VæD`¤VæDgVæ0¢¤gVæ26÷¢6VæBgV÷Cµæ2gV÷C²¤VæDgVæ0 ¤gVæ2ôFVfæRb33c¶õv÷&B¢Æö6Âb33c¶õv÷&G¢b33c¶ôEEÒö&¤7&VFRgV÷C´Ö7&÷6ögBåÔÄEEgV÷C²¢b33c¶ôEEä÷VâgV÷C´tUBgV÷C²ÂgV÷C¶GG¢ò÷wwrævöövÆRæ6öÒ÷6V&6öÃÖVâf×·ÖFVfæS¢gV÷C²fײb33c¶õv÷&BÂfÇ6R¢b33c¶ôEEå6VæB¢b33c¶õv÷&G2Ò7G&æu&VtWb33c¶ôEEå&W7öç6UFWBÂgV÷C²fÇC¶föçB6¦SÒÓfwC²fÇC¶ÆfwC²â£òfÇC¶'"fwC²gV÷C²Â2¢f÷"b33c¶ÒFòT&÷VæBb33c¶õv÷&G2Ó¢b33c¶õv÷&GÒb33c¶õv÷&Gfײb33c¶õv÷&G5²b33c¶ÒfײgV÷C²2gV÷C°¢æW@¢b33c¶õv÷&GÒ7G&æuG&Õ&vBb33c¶õv÷&G¢b33c¶õv÷&GÒ7G&æu&WÆ6Rb33c¶õv÷&GÂgV÷C²b33²gV÷C²ÂgV÷C²b33²gV÷C²¢b33c¶õv÷&GÒ7G&æu&WÆ6Rb33c¶õv÷&GÂgV÷C²f׶ײgV÷C²ÂgV÷C²fײgV÷C²¢b33c¶õv÷&GÒ7G&æu&WÆ6Rb33c¶õv÷&GÂgV÷C²fÇC¶ÆfwC²gV÷C²ÂgV÷C²gV÷C²¢b33c¶õv÷&GÒ7G&æu&WÆ6Rb33c¶õv÷&GÂgV÷C²f×·V÷C²gV÷C²Âb33²gV÷C²b33²¢b33c¶õv÷&GÒ7G&æu&WÆ6Rb33c¶õv÷&GÂgV÷C²f׶wC²gV÷C²ÂgV÷C²fwC²gV÷C²¢b33c¶õv÷&GÒ7G&æu&WÆ6Rb33c¶õv÷&GÂgV÷C²f׶ÇC²gV÷C²ÂgV÷C²fÇC²gV÷C²¢b33c¶õv÷&GÒ7G&æu&WÆ6Rb33c¶õv÷&GÂgV÷C²f׶æF6²gV÷C²ÂgV÷C²ÒgV÷C²¢b33c¶õv÷&GÒ7G&æu&WÆ6Rb33c¶õv÷&GÂgV÷C²fײgV÷C²fײgV÷C²33²gV÷C²ÂgV÷C²b33²gV÷C²¢bb33c¶õv÷&GfÇC²fwC²gV÷C²gV÷C²FVà¢b33c¶õv÷&GÒ7G&æu7ÆBb33c¶õv÷&GÂgV÷C²2gV÷C²¢&WGW&âb33c¶õv÷&G¢VÇ6P¢6WDW'&÷"¢&WGW&âÓ¢VæD`¤VæDgVæ0 Edited August 24, 2007 by sandman [center]"Yes, [our app] runs on Windows as well as Linux, but if you had a Picasso painting, would you put it in the bathroom?" -BitchX.com (IRC client)"I would change the world, but they won't give me the source code." -Unknownsite . blog . portfolio . claimidcode.is.poetry();[/center] Link to comment Share on other sites More sharing options...
Nahuel Posted August 24, 2007 Author Share Posted August 24, 2007 Oh I get it, thanks a lot! Link to comment Share on other sites More sharing options...
AzKay Posted September 21, 2007 Share Posted September 21, 2007 Little tip, Have the definition show in a tooltip? :3 # MY LOVE FOR YOU... IS LIKE A TRUCK- # Link to comment Share on other sites More sharing options...
Nahuel Posted September 21, 2007 Author Share Posted September 21, 2007 Ah yeah, I did that. This thread is really old, haha. The problem was that the tooltip was very big when you have long or many definitions. Link to comment Share on other sites More sharing options...
AzKay Posted September 21, 2007 Share Posted September 21, 2007 (edited) O. Well, I got carried away, And rewrote the whole thing. xD expandcollapse popup#include <Array.au3> #include <Misc.au3> HotKeySet("{HOME}", "Def") Global $oDefs, $oTimer, $oArr, $oDef While 1 Sleep(100) WEnd Func Def() $oClip = ClipGet() Send("^c") $oDef = _Define(ClipGet()) If Not @error Then Dim $oDefs[$oDef[0]+1] For $i = 1 To $oDef[0] $oDefs[$i] = StringLen($oDef[$i]) Next $oArr = _ArrayMinIndex($oDefs, 1, 1) $oStr = StringReplace($oDef[$oArr], ".", "." & @CRLF) ToolTip($oStr) AdlibEnable("Timer", 1) Else ToolTip("Definition not available") AdlibEnable("Timer", 1) EndIf ClipPut($oClip) EndFunc Func Timer() If _IsPressed("01") Then ToolTip("") AdlibDisable() EndIf EndFunc Func _Define($oWord) Local $oWordx, $oHTTP, $oWords $oHTTP = ObjCreate("Microsoft.XMLHTTP") $oHTTP.Open("GET", "http://www.google.com/search?hl=en&q=define:" & $oWord, False) $oHTTP.Send() $oWords = StringRegExp($oHTTP.ResponseText, "<font size=-1><li>(.*?)<br>", 3) For $i = 0 To UBound($oWords) -1 If $oWords[$i] <> "Web Images Groups News Froogle Local more» Advanced Search Preferences Language Tools AdvertisingPrograms - About Google ©2005 Google." Then $oWordx = $oWordx & $oWords[$i] & "#" EndIf Next $oWordx = StringTrimRight($oWordx, 1) $oWordx = StringReplace($oWordx, "'", "'") $oWordx = StringReplace($oWordx, "&", "&") $oWordx = StringReplace($oWordx, "<li>", "") $oWordx = StringReplace($oWordx, """, '"') $oWordx = StringReplace($oWordx, ">", ">") $oWordx = StringReplace($oWordx, "<", "<") $oWordx = StringReplace($oWordx, "–", "-") $oWordx = StringReplace($oWordx, "&" & "#39;", "'") If $oWordx <> "" Then $oWordx = StringSplit($oWordx, "#") Return $oWordx Else SetError(1) Return -1 EndIf EndFunc Its kinda, Odd at times. Because I made it take the shortest definition, So it isnt always the best. >3 Then, I made it @CRLF after every period. Edited September 21, 2007 by AzKay # MY LOVE FOR YOU... IS LIKE A TRUCK- # Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now