Code: Select all
; Upgraded: select the world to the left of the cursor, and correct using Google:
^+!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
Yet, it usually take me a few more words to notice that I should have typed something wrong. Thus, I am looking for a way to move the cursor to the previous "wrongly spelled word", and put the corresponding code to the top of the aforementioned script.
Specifications: I use Firefox mainly, and some Email client called Kiwi (which is really bad for its spell-checking/correcting function). At this point, I am not sure if the cursor-movement snippet should be context dependent. Frankly speaking, I am totally blank on how to implement such cursor movement.