Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Script for All-Purpose Spell Checker


  • Please log in to reply
7 replies to this topic
Diamond
  • Members
  • 198 posts
  • Last active: Dec 02 2015 11:18 AM
  • Joined: 31 Mar 2006
Thanks MsgBox, this
http://www.autohotke... ... ll checker
was a good idea, so I stole it. However, since I'm visually impaired and I rely on screen reading software, I needed something with a windows GUI. This script is for All-Purpose Spell Checker.
http://www.math.mcgi...gs/apscinst.exe
This should work on either selected text or the entire document otherwise.

;Spell Check with APSC
Pause::
BlockInput On
WinGet ID, ID, A
AutoTrim Off
CS = %ClipboardAll%
Clipboard =
SendInput ^c
ClipWait 0.1
If Clipboard =
{
SendInput ^a
SendInput ^c
ClipWait
}
PRTXT = %Clipboard%
Process Exist, APSC.exe
APSCPID = %ErrorLevel%
If APSCPID = 0
{
Run C:\Program Files\Palware\APSC 4.0\APSC.exe,,, APSCPID
WinWait ahk_class ThunderRT5Form ahk_pid %APSCPID%
IfWinNotActive ahk_class ThunderRT5Form ahk_pid %APSCPID%
WinActivate ahk_class ThunderRT5Form ahk_pid %APSCPID%
}
Else
{
WinShow ahk_class ThunderRT5Form ahk_pid %APSCPID%
WinActivate ahk_class ThunderRT5Form ahk_pid %APSCPID%
}
WinWaitActive ahk_class ThunderRT5Form ahk_pid %APSCPID%
Loop
{
ControlFocus RichTextWndClass1, ahk_class ThunderRT5Form ahk_pid %APSCPID%
ControlGetFocus Focus, ahk_class ThunderRT5Form ahk_pid %APSCPID%
If Focus = RichTextWndClass1
Break
}
Sleep 100
SendInput ^v
ControlGetPos XPos, YPos,,, ThunderRT5PictureBox1, ahk_class ThunderRT5Form ahk_pid %APSCPID%
Click %XPos%, %YPos%
WinWaitActive Misspelled Word Found ahk_class #32770 ahk_pid %APSCPID%,, 1
BlockInput Off
If ErrorLevel = 1
{
MsgBox 64, All-Purpose Spell Checker, No misspelled words found.
WinClose ahk_class ThunderRT5Form ahk_pid %APSCPID%
WinActivate ahk_id %ID%
Clipboard = %CS%
APSCPID =
CS =
Focus =
ID =
PRTXT =
Return
}
WinWaitClose Misspelled Word Found ahk_class #32770 ahk_pid %APSCPID%
BlockInput On
Loop
{
ControlGetFocus Focus, ahk_class ThunderRT5Form ahk_pid %APSCPID%
If Focus = RichTextWndClass1
Break
}
Clipboard =
SendInput ^s
ClipWait
WinClose ahk_class ThunderRT5Form ahk_pid %APSCPID%
WinActivate ahk_id %ID%
If (PRTXT != Clipboard)
{
WinWaitActive ahk_id %ID%
SendInput ^v
Sleep 100
}
BlockInput Off
Clipboard = %CS%
APSCPID =
CS =
Focus =
ID =
PRTXT =
Return

The built-in hotkey Ctrl+k activates the spell checking once you've copied the text into the program, but there seems to be a strange bug which somehow replaces the first occurrence of a misspelled word with the "k" from this key combination. This is why I use the "ControlGetPos" and "Click" lines instead.

toralf
  • Moderators
  • 4035 posts
  • Last active: Aug 20 2014 04:23 PM
  • Joined: 31 Jan 2005
Dear Diamond,

I moved your script into the script section.

Thanks for sharing.
Ciao
toralf
 
I use the latest AHK version (1.1.15+)
Please ask questions in forum on ahkscript.org. Why?
For online reference please use these Docs.

Diamond
  • Members
  • 198 posts
  • Last active: Dec 02 2015 11:18 AM
  • Joined: 31 Mar 2006
A couple of small fixes.

slomz
  • Members
  • 601 posts
  • Last active: Mar 30 2008 12:54 AM
  • Joined: 03 Sep 2006
Very nice script.

Diamond
  • Members
  • 198 posts
  • Last active: Dec 02 2015 11:18 AM
  • Joined: 31 Mar 2006
The previous method for activating the spell check dialog wasn't working consistently enough. Hopefully this will work better, but we shall see.

Diamond
  • Members
  • 198 posts
  • Last active: Dec 02 2015 11:18 AM
  • Joined: 31 Mar 2006
Some small changes.

Diamond
  • Members
  • 198 posts
  • Last active: Dec 02 2015 11:18 AM
  • Joined: 31 Mar 2006
Some minor changes.
I also added "SetTitleMatchMode 3" to the script because it doesn't seem to work correctly when you have TitleMatchMode set globally to RegEx. I'm not quite sure why.

Diamond
  • Members
  • 198 posts
  • Last active: Dec 02 2015 11:18 AM
  • Joined: 31 Mar 2006
The script now uses the active window's ID instead of the cumbersome Title/Class/PID method I was previously using. This also eliminates the need for "SetTitleMatchMode".