Cursor to the previously wrongly spelled word

Get help with using AutoHotkey and its commands and hotkeys
llinfeng
Posts: 46
Joined: 08 Dec 2016, 21:54
GitHub: llinfeng

Cursor to the previously wrongly spelled word

26 Sep 2018, 12:16

I am having the following script to visit Google and correct the word that is directly "in front of" the cursor:

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
Credits to this original post.

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.

Return to “Ask For Help”

Who is online

Users browsing this forum: boiler, Google [Bot], mladpetco, TCO and 221 guests