Jump to content

Google Spelling Help (Googler)


Skizmata
 Share

Recommended Posts

You got me inspired, so I had to write something hehe. This one I wrote will display a list of alternative spellings allowing the user to select the word to replace misspelled word with.

1. Select the misspelled word.

2. Press ctrl+g

3. That word selected is placed on the clipboard.

#include <INet.au3>
#include <String.au3>
#include <array.au3>
#include <IE.au3>
#include <misc.au3>
#include <GuiConstants.au3>
#include <GuiList.au3>

_Singleton("checkthis")
$GUI = GUICreate("Spelling alternitives",300,310,-1,-1,$WS_POPUP + $WS_BORDER, $WS_EX_TOPMOST, $WS_EX_TOOLWINDOW)
$listwords = GUICtrlCreateList("",10,10,280,300,BitOR($WS_BORDER, $WS_VSCROLL))
WinSetOnTop("Spelling alternitives","",1)
HotKeySet("^g","_SpellCheck")

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit
        Case $msg = $listwords
            Local $chosenword = _GUICtrlListGetText($listwords,_GUICtrlListSelectedIndex($listwords))
            ClipPut($chosenword)
            GUISetState(@SW_HIDE,$GUI)
            HotKeySet("^g","_SpellCheck")
            TrayTip($chosenword,"Stored on clipboard",1,1)
    EndSelect
WEnd

Func _SpellCheck()
    HotKeySet("^g")
    Send("^c")
    If ClipGet() <> "" Then
        Local $html = _INetGetSource("http://www.spellcheck.net/cgi-bin/spell.exe?action=CHECKWORD&string=" & ClipGet())
        If @error <> 1 Then
            If StringRegExp($html,"is spelled correctly") = 1 Then
                HotKeySet("^g","_SpellCheck")
                ToolTip("""" & ClipGet() & """" & " is spelled correctly")
                Sleep(3000)
                ToolTip("")
            Else
                Local $list = _StringBetween($html,"<BLOCKQUOTE>","</BLOCKQUOTE>")
                GUISetState(@SW_SHOW,$GUI)
                Local $words = StringSplit(StringRegExpReplace($list[0],"<BR>",@CRLF),@CRLF)
                _GUICtrlListClear($listwords)
                For $i = 1 To $words[0] - 1
                    If $words[$i] > "" Then
                        _GUICtrlListAddItem($listwords,$words[$i])
                    EndIf
                Next
            EndIf
        EndIf
        HotKeySet("^g","_SpellCheck")
    EndIf
EndFunc
Edited by Toady

www.itoady.com

A* (A-star) Searching Algorithm - A.I. Artificial Intelligence bot path finding

Link to comment
Share on other sites

It will be better if you use the real Google Spellcheck API, as described here, but it needs messing with HTTP headers etc...

I think this way it will be A LOT faster, since you will need to download only the results from the spellcheck (its a XML). Check the link I gave you. Maybe you will get some ideas.

Thanks for the link however I'm a huge rookie when it comes to AutoIt/Programing every project I do I learn allot from. Time to learn to use API's in autoit!

I just know I can do that, although I don't want to install the Google tool bar to analyze the packets it is sending.. :whistle:

What do you use to analyze these packets. I know a bit about network protocols but not allot about them from the programing/manipulating side.

You got me inspired, so I had to write something hehe. This one I wrote will display a list of alternative spellings allowing the user to select the word to replace misspelled word with.

1. Select the misspelled word.

2. Press ctrl+g

3. That word selected is placed on the clipboard.

CODE WAS HERE

Wow thanks for the contribution Toady as a big fan of your work it is a honor to have you contributing to a thread based on something I wrote. If you wouldent mind I might like to include some of that in my own personal version of Googler.

Thanks all!!!!

AutoIt changed my life.

Link to comment
Share on other sites

You got me inspired, so I had to write something hehe. This one I wrote will display a list of alternative spellings allowing the user to select the word to replace misspelled word with.

I like yours as well. I made a few changes to suit the way I like things, hope you don't object.

These things are excellent for these forums; you just double click on a word which has a red underline and press the splell checker hot key.

BTW you should have a look at xenobiologist's organizeincludes - you have includes which aren't needed.

But I think we are in danger of high jacking Skizmata's thread.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

What do you use to analyze these packets. I know a bit about network protocols but not allot about them from the programing/manipulating side.

Well, first of all you need to capture a few packets. I love to use WPE Pro, which is free.

So, you capture 1 full transmission, from start to finish. Then you start analyzing that by looking at one entire packet.

I except something that resembles a HTTP packet.

GET /DataThatIsImportant.xml HTTP/1.1
More important header data
BIG HEX CODE
More data

On that API page I read something about where the hex might be from and how it is generated. So, I would check if it is important or I can just use the same code over and over again (probably not).

So, then you try to recreate that packet in AutoIt, using TCPSend.. Capture the incoming packet, and parse that..

Not much more to it, and this is an elaborate description of what I would do.. Although, it has a 50%-50% chance of succes.. :whistle:

Link to comment
Share on other sites

But I think we are in danger of high jacking Skizmata's thread.

High Jack away! This is good stuff!

Well, first of all you need to capture a few packets. I love to use WPE Pro, which is free.

So, you capture 1 full transmission, from start to finish. Then you start analyzing that by looking at one entire packet.

I except something that resembles a HTTP packet.

GET /DataThatIsImportant.xml HTTP/1.1
More important header data
BIG HEX CODE
More data

On that API page I read something about where the hex might be from and how it is generated. So, I would check if it is important or I can just use the same code over and over again (probably not).

So, then you try to recreate that packet in AutoIt, using TCPSend.. Capture the incoming packet, and parse that..

Not much more to it, and this is an elaborate description of what I would do.. Although, it has a 50%-50% chance of succes.. :whistle:

Thank you! I have downloaded WPE Pro and will be tinkering with it momentarily. Thanks so much for the pointer, I hope you don't mind if I bug you on this in the future.

@skizmata

No prob, I don't take credit in the script I wrote, it was just something that interested me. Do what ever you choose, thanks again.

@martin

I really wasn't trying to make it an official script, it was just something i did for fun.

Thanks Toady I appreciate your free and open nature.

(Googler used twice in writing this post.)

AutoIt changed my life.

Link to comment
Share on other sites

  • 5 months later...

I'd like to light a fire under this thread again since i'm looking for a very light weight spell checking solution myself. What i need to do is check a document, or the contents of an edit control (or clipboard). I also like google because of it's ability to "think" like i do and correct spelling mistakes that most other solutions miss. I think this may be the answer and it's powered by google, aspell and texttrust...

# This spell check application lets you check for spelling mistakes from any system or computer that has Internet access.

# Your privacy is important - no text is logged.

# You can spell check in 27 languages: Bahasa Indonesia, Četina, Dansk, Deutsch, ελληνικά, English, Español, Eesti keel, Français, עִבְרִית, हिंदी, Hrvatski, Italiano, Latvieu, Lietuvių, kalba, Nederlands, Norsk, Polski, Português, Română, Slovenčina, Slovenčina, Suomi, Svenska, Türkçe and РУССКИЙ!

# Powered by Google, Aspell and TextTrust - probably the best spell checkers around!

# In the future you may need to spell check some text, why not bookmark this service?

# The spell check code is free, you can use it in your own web applications. This spell checker is open source and the code can be downloaded here.

http://www.orangoo.com/spell/

thoughts?

Link to comment
Share on other sites

Good work :3

Also made me want to rewrite it using httprequests x3

$oHTTP = ObjCreate("winhttp.winhttprequest.5.1")
$oHTTP.Option(0) = "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.11) Gecko/20071127 Firefox/2.0.0.11"
Global $oTimer

HotKeySet("^e", "_SpellCheck")

While 1
    Sleep(100)
    If TimerDiff($oTimer) > 2000 Then
        ToolTip("")
        $oTimer = ""
    EndIf
WEnd

Func _SpellCheck()
    Send("^c")
    $oHTTP.Open("GET", "http://www.google.com/search?hl=en&q=" & ClipGet(), False)
    $oHTTP.Send()
    $oSpell = __StringBetween($oHTTP.ResponseText, "spell=1 class=p><b><i>", "</i></b>")
    If $oSpell <> "" Then
        ToolTip($oSpell)
        ClipPut($oSpell)
    Else
        ToolTip("No found spelling")
    EndIf
    $oTimer = TimerInit()
EndFunc

Func __StringBetween($s, $from, $to)
    $x = StringInStr($s, $from) + StringLen($from)
    $y = StringInStr(StringTrimLeft($s, $x), $to)
    Return StringMid($s, $x, $y)
EndFunc
# MY LOVE FOR YOU... IS LIKE A TRUCK- #
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...