Jump to content

Google Spelling Help (Googler)


Skizmata
 Share

Recommended Posts

This is my first script submission so be easy on me if its lame. I have a horrible speller and a prolific user of spell check. However my misspellings don't seem to jive with what most spell checkers think the word should be. However I have found help! Google seems to get me, if I misspell a word Google seems to get what I mean with the "Did you mean". So I usualy have a Google window open in my FireFox so I can check Google. I ended up writing a program to help me do that with I'm sure it will make sense to you guys.

How to use: High lite a misspelled word and press Ctrl+g

I understand this might seem useless to many of you but I have used it a half a dozen times writing this post.

Thanks to Martin for the auto copy and paste idea.

#include <INet.au3>
#include <String.au3>
#include <array.au3>

HotKeySet("^g", "_Googler")

AutoItSetOption("TrayAutoPause",0)

TraySetIcon ( @ScriptDir & 'Googler.exe')

TraySetState()
TraySetToolTip("Press Ctrl+G to Google Your Cliboard Text and Get A Spelling Correction Sent Back To Your Clipboard.")

while 1
    sleep(500)
WEnd

Func _Googler()
    Send("^c")
    $PageSource = _INetGetSource ( "http://www.google.com/search?hl=en&safe=off&client=firefox-a&rls=org.mozilla%3Aen-US%3Aofficial&q=" & Clipget() &"&btnG=Search" )
    $Output = _StringBetween($PageSource, 'class=p><b><i>', '</i></b></a>&nbsp;&nbsp;')
    If $OutPut = '' Then
        $ClipBoard = ClipGet()
        TrayTip("Googler", "No spelling help found.", 2, 1)
        Return
    EndIf

    send($OutPut[0])
EndFunc

Also attached is a google icon I ripped when you compile add it to your exe and it will show up on the tray Icon.

P.S. I actually use this so any input on how to make it better would be helpful.

Also I would like to make a version of this with no tray icon or GUI at all I don't like the clutter. I added AutoItSetOption("TrayIconHide",1) to the script but the Icon still shows up any ideas?

Google.ico

Edited by Skizmata

AutoIt changed my life.

Link to comment
Share on other sites

This is my first script submission so be easy on me if its lame. I have a horrible speller and a prolific user of spell check. However my misspellings don't seem to jive with what most spell checkers think the word should be. However I have found help! Google seems to get me, if I misspell a word Google seems to get what I mean with the "Did you mean". So I usualy have a Google window open in my FireFox so I can check Google. I ended up writing a program to help me do that with I'm sure it will make sense to you guys.

How to use: Copy a misspelled word to your clipboard. Press Ctrl+G and if Google has a spelling suggestion for you it puts that in your clipboard.

I understand this might seem useless to many of you but I have used it a half a dozen times writing this post.

; Written entirely by Skizmata of www.AutoItscripts.com/Forum/ with the help of the community.
#include <INet.au3>
#include <String.au3>

HotKeySet("^g", "_GoogleSpell")

TraySetIcon ( @ScriptDir & 'Googler.exe')

TraySetState()
TraySetToolTip("Press Ctrl+G to Google Your Cliboard Text and Get A Spelling Correction Sent Back To Your Clipboard.")

while 1
    sleep(250)
WEnd

Func _GoogleSpell()
    $PageSource = _INetGetSource ( "http://www.google.com/search?hl=en&safe=off&client=firefox-a&rls=org.mozilla%3Aen-US%3Aofficial&q=" & Clipget() &"&btnG=Search" )
    $Output = _StringBetween($PageSource, 'class=p><b><i>', '</i></b></a>  ')
    If $OutPut = '' Then
        $ClipBoard = ClipGet()
        TrayTip("Googler", "No spelling help found.", 2, 1)
        Return
    EndIf

    ClipPut($OutPut[0])
EndFunc

Also attached is a google icon I ripped when you compile add it to your exe and it will show up on the tray Icon.

P.S. I actually use this so any input on how to make it better would be helpful.

It's a very good idea, and it works well. :whistle:

I think you need to remove the spaces after </a> because I don't always have any spaces there.

If you are feeling confident, and assuming you check a word by highlighting a word then pressing Ctrl c then Ctrl G, why not miss out pressing Ctrl C and make _Googlespell copy the contents of the clipboard, send("^c") , and if the clipboard contains anything then do what you already do and then if something is found send("+{INSERT}"). Finally put back into the clipboard what was there originally. That would make it a bit slicker.

I used your script to correct a spelling in this post!

You could even develop the function so that you could highlight a whole lot of text, split it into individual words, spell check and replace each one etc.

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

Took the spaces out after the </a> as suggested. And I think I will use your other suggestion Martin! Thanks for liking it!

I wish I had more of an idea why it doesn't work for you JBr00ks I would love to fix it for you if I had a bit more info.

*EDIT*

Added automatic copy and paste thanks to Martin

Edited by Skizmata

AutoIt changed my life.

Link to comment
Share on other sites

Great Idea, unfortunately I get the same result as JBr00ks.

I have tried it lots of times and it usually works. The problem when you don't get a result is sometimes because Google manages to find something with that word. (It is interesting to see that Google also tries other search engines to find things.)

If you try "yu" or "chang", which could easily be "you" and "change", you get nothing back, so my conclusion is that something more than Google is needed.

@Skizmata: Have you looked at places like Splellcheck.net? You could have another option, to search for a list of possible words which would be quite easy. It might be that if Google returns nothing, like say it does for "yu" then you could try Spellcheck.net, or some other online spell checker which gives a list of possible words.

It would be convenient to have some way to give people an option to change the hot key.

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

I will look into having an option to change the hotkey thanks again Martin. Also thanks for the Spellcheck.net suggestion the reason I wrote it they way I did is I for programs which allready have spell check to fill in what I feel is a gap in spellchecks at places like this or Lotus Notes at work I am thinking about working on another kind of spell checker but this is not really meant to be that.

If you guys who are having trouble, could give me some of the example words that I could use for testing. It seems its likely what Martin is saying this isn't a spell checker its a google "did you mean"er. So it wont fix things like "yu" or "chang".

Thanks for your interest in this first timer's program.

AutoIt changed my life.

Link to comment
Share on other sites

Praise from my heroes of AutoIt!!! I'm so psyched (it actually got that from syced) it means the world to me to get the thumbs up from you guys. It might be basic but I will actually be using this program every day heh. Thanks again! Now if I could figure out how to put this in my signature like you guys!

AutoIt changed my life.

Link to comment
Share on other sites

Praise from my heroes of AutoIt!!! I'm so psyched (it actually got that from syced) it means the world to me to get the thumbs up from you guys. It might be basic but I will actually be using this program every day heh. Thanks again! Now if I could figure out how to put this in my signature like you guys!

http://www.autoitscript.com/forum/index.ph...rCP&CODE=22
Link to comment
Share on other sites

..for programs which allready have spell check to fill in what I feel is a gap in spellchecks.

Ah yes, that's a really good way to use it. The whole idea really appeals to me because it is so easy to add spell checking to any program (or extend the spell checking). I wrote a script to solve codeword puzzles which used an on-line spell checker, but it never occurred to me to do this.

I've thought of it now though. Thanks Skizmata.

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

Just made couple very minor changes. I toyed around with making Google Calc stuff work with it (it can do math and conversions) however I ran into trouble since I can't really just plug 8+5 into a URL to use the Calc. (Experiment with it and you will see what I mean.) I would appreciate any help example code or recommendations as to how to incorporate Google Calc functionality.

AutoIt changed my life.

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.

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.

Definitely worth investigating, though I think it's quite fast already.

Here is the sort of thing that might do the calc idea.(might be different for google.com instead of google.co.uk)

Only given it a quick test so not confident.

Func _GoogleCalc()
 $ClipBoard = ClipGet()
 Send("^c")
 $calc = ClipGet()
 $Calc = StringLower($calc)
 $Calcstart = "http://www.google.co.uk/search?hl=en&q="
 $calcend = "&btnG=Search&meta="

 $calc = StringStripWS($calc,8)
 $Scalc = StringReplace($calc,'-',' - ')
 $Scalc = StringReplace($Scalc,'*',' * ')
 $Scalc = StringReplace($Scalc,'+',' + ')
  $Scalc = StringReplace($Scalc,'/',' / ')
  $Scalc = $Scalc & ' = ';now $scalc is the string in the $pagesource

 $calc = StringReplace($calc,'(','%28')
 $calc = StringReplace($calc,')','%29')
 $calc = StringReplace($calc,'+','%2B')
 $calc = StringReplace($calc,'/','%2F');might be other things to replace
;MsgBox(0,'calc is now',$calc)
;MsgBox(0,'scalc is now',$scalc)
 $PageSource = _INetGetSource ( $CalcStart & $calc & $CalcEnd)
 If StringInStr($pagesource,$scalc) = 0 Then
     MsgBox(0,'Error','Cannot work that one out')
 Else
  $Output = _StringBetween($PageSource, $Scalc, '</b>');</h2></td></tr><tr><td>&nbsp;')
  if Isarray($Output) then Send($Output[0])
EndIf

ClipPut($ClipBoard)

EndFunc

EDIT:convert $calc to lower case

EDIT2: I see from the next post that Paulie beat me to this, and did more.

See Paulie's post

Edited by martin
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

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.

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