Created
November 4, 2018 16:53
-
-
Save llinfeng/5e6ba65c0278d7380aa064f250e00c06 to your computer and use it in GitHub Desktop.
Use AutoHotKey + Google for spell-checking: in Normal text editors
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; How it works? Well, when you type a single word with erranous spellings to Google, it way "Did you mean ...". | |
; This AHK script grab that piece of Google Suggestion and pass it back to the clipboard. | |
; Purpose: select the world to the left of the cursor, and correct using Google: | |
; Credits: AutoHotkey Community (Linfeng is not able to find the original source.) | |
; Please comment if you are able to find the source of those fantastic regex expressions | |
;; Usage: use Ctrl + Alt + Shift + H, to select the word to the left of your active cursor, | |
;; and replace it with whatever Google corrects it to be. | |
;; Warning: only work best for very-close, but wrong, spellings. | |
^+!h:: | |
send {CTRLDOWN}{SHIFTDOWN}{LEFT}{CTRLUP}{SHIFTUP} | |
clipback := ClipboardAll | |
clipboard= | |
Send ^c | |
ClipWait, 0 | |
UrlDownloadToFile % "https://www.google.com/search?q=" . clipboard, temp | |
FileRead, contents, temp | |
FileDelete temp | |
if (RegExMatch(contents, "(Showing results for|Did you mean:)</span>.*?>(.*?)</a>", match)) { | |
StringReplace, clipboard, match2, <b><i>,, All | |
StringReplace, clipboard, clipboard, </i></b>,, All | |
clipboard := RegExReplace(clipboard, "'", "'") | |
clipboard := RegExReplace(clipboard, "&", "&") | |
} | |
Send ^v | |
Sleep 500 | |
clipboard := clipback | |
; MsgBox You are right ; As something new, and inline comment is admissible. | |
return |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment