AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Script for All-Purpose Spell Checker

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
Diamond



Joined: 31 Mar 2006
Posts: 127
Location: New York

PostPosted: Thu Sep 14, 2006 9:26 am    Post subject: Script for All-Purpose Spell Checker Reply with quote

Thanks MsgBox, this
http://www.autohotkey.com/forum/viewtopic.php?t=12584&highlight=spell+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.mcgill.ca/rags/apscinst.exe
This should work on either selected text or the entire document otherwise.

Code:
;Spell Check with APSC
Break::
WinGet ID, ID, A
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
WinWaitActive 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
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%
CS =
Focus =
PRTXT =
ID =
APSCPID =
Return
}
WinWaitClose Misspelled Word Found ahk_class #32770 ahk_pid %APSCPID%
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
}
Clipboard = %CS%
CS =
Focus =
PRTXT =
ID =
APSCPID =
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.


Last edited by Diamond on Sat Jun 02, 2007 10:30 am; edited 12 times in total
Back to top
View user's profile Send private message
toralf



Joined: 31 Jan 2005
Posts: 3841
Location: Bremen, Germany

PostPosted: Thu Sep 14, 2006 9:39 am    Post subject: Reply with quote

Dear Diamond,

I moved your script into the script section.

Thanks for sharing.
_________________
Ciao
toralf
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Diamond



Joined: 31 Mar 2006
Posts: 127
Location: New York

PostPosted: Sat Sep 16, 2006 4:41 pm    Post subject: Reply with quote

A couple of small fixes.
Back to top
View user's profile Send private message
slomz



Joined: 03 Sep 2006
Posts: 608
Location: Iowa, U.S.

PostPosted: Sat Sep 16, 2006 7:37 pm    Post subject: Reply with quote

Very nice script.
Back to top
View user's profile Send private message AIM Address
Diamond



Joined: 31 Mar 2006
Posts: 127
Location: New York

PostPosted: Tue Sep 19, 2006 4:08 am    Post subject: Reply with quote

The previous method for activating the spell check dialog wasn't working consistently enough. Hopefully this will work better, but we shall see.
Back to top
View user's profile Send private message
Diamond



Joined: 31 Mar 2006
Posts: 127
Location: New York

PostPosted: Wed Oct 25, 2006 7:59 pm    Post subject: Reply with quote

Some small changes.
Back to top
View user's profile Send private message
Diamond



Joined: 31 Mar 2006
Posts: 127
Location: New York

PostPosted: Thu May 31, 2007 1:27 am    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
Diamond



Joined: 31 Mar 2006
Posts: 127
Location: New York

PostPosted: Sat Jun 02, 2007 10:19 am    Post subject: Reply with quote

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".
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group