mIRC Spelling & Grammar Check

Platform:  mIRC
Published  Jun 20, 2011
Updated  Jan 26, 2012
This snippet Uses MS Word's(2003 or later) API and mIRC's COMs to spell/grammar check your text. If there is an incorrect word a dialog will pop up asking you to replace or ignore it. If everything is spelled correctly, the dialog won't appear.
If for whatever reasons, the spell/grammar check dialog opens behind your mIRC, hold the alt key, and (keep) pressing tab until the MS Word Icon is selected then release both keys. This will bring the dialog to the forground.

The Script will need:
mIRC 6.2x or later
MS Windows 2000 or later
MS Word 2003 or later

To Load:
place in a fresh remotes file

To Use:
Type in the edit box, press shift+enter to spell/grammar check the text before sending

Notes:
Due to WINE's lack of com support, this will not work with mIRC ran under WINE
Having other "on INPUT" events may cause problems with this/that/those script(s) .
To fix this issue add the following line as the first command to be executed from those scripts' on input events:

Code

 


Screen Shot:
http://i55.tinypic.com/24xevc7.png

Updates:
January 26, 2012
Now using a variable instead of an empty group
Fixed to work with queries now
Bug with the dialog opening behind mIRC still eludes me :<

December 27, 2011
Added Grammar Checking.
Added Menu to channel and query windows to toggle Checks
Can now toggle Spelling and/or Grammar checks on or off
Fixed cleanup not happening on disabling

July 03, 2011
Added a 'windowstate set' to hopefully fix the spellcheck dialog opening behind mIRC

June 20, 2011
Added Check to make sure mIRC is not set as ontop
Did some reorganizing of the code[removed all those goto's]
On Input now calls the $SpellCheck immediately, and then uses a timer to set the editbox text
Changed timer from -h to -m[-h was causing a recusion bug]
Cleaned up the code.



Comments/Flames/Questions/Suggestions are GREATLY appreciated.... Without user input there can not be developer output
menu channel,query {
Spelling and Grammar Check
.$submenu($SGC:Menu($1-))
}
alias -l SGC:Safe bset -ct &a 1 $1 | return $!regsubex(safe, $bvar(&a,1-) ,/(\d+)(?: |$)/g,$chr(\1))
alias -l SGC:Conf if ($isid) return $isbit(%SGC:Conf,$1) | set %SGC:Conf $xor($iif(%SGC:Conf,$v1,0),$calc(2^($1 -1)))
alias -l SGC:Menu {
if ($SGC:Conf(1) && $1 == 1) return Disable: SGC:Cleanup $(|) SGC:Conf 1
elseif ($1 == 1) return Enable:SGC:Conf 1
elseif ($1 == 2) return $iif($calc($iif(!$SGC:Conf(1),2) + $iif($SGC:Conf(2),1)),$style($v1)) CheckGrammar: SGC:Conf 2
}
alias SGC:Cleanup {
if ($com(SGC:Con)) .comclose $v1
if ($com(SGC:Doc)) .comclose $v1 $com($v1,Close,1,bool,false)
if ($com(SGC:Docs)) .comclose $v1
if ($com(SGC:Word)) .comclose $v1 $com($v1,Quit,1)
}

on *:LOAD:{
SGC:Cleanup
if ($os isin 95 98) %r = You need atleast Windows 2000 or later for this script to function
elseif ($version < 6.2) %r = You need to be using mIRC 6.2 or later for this script to function
else {
.comopen SGC:Word word.Application
if ($comerr) %r = You need Microsoft Word 2003 or later installed for this script to function
}
if (%r) {
echo -ag * $+($chr(2),$chr(3),04Spelling and Grammar Check,$chr(15),:) %r
.timer -m 1 1 .unload -rs $qt($script)
}
else {
set %SGC:Conf 3
echo -ag * $+($chr(2),$chr(3),03Spelling and Grammar Check,$chr(15)) is now loaded and functional
}
}
on *:INPUT:*:{
if ($window($active).type isin channel query) && (!$inpaste && !$ctrlenter && $isbit($mouse.key,3)) {
if (!$SGC:Conf(1)) {
.timer -m 1 1 editbox -n $SGC:Safe($active $1-)
halt
}
var %r
if (!$com(SGC:Word) || !$com(SGC:Docs) || !$com(SGC:Doc)) {
SGC:Cleanup
.comopen SGC:Word word.Application
if ($comerr) %r = You must have Microsoft Word 2003 or later installed for this script to work
elseif (!$com(SGC:Word,Visible,5,bool,false)) %r = Unable to hide MS Word COM window
elseif (!$com(SGC:Word,Documents,2,dispatch* SGC:Docs)) %r = Unable to get get list of open MS Word COM documents.
elseif (!$com(SGC:Docs,Add, 1,error,,error,,error,, bool,false,dispatch* SGC:Doc)) %r = Unable to create a new MS Word COM document.
}
if (!%r) {
if (!$com(SGC:Doc,Content,4,bstr,$1-)) %r = Unable to copy text to be Spell and/or Grammar checked into the MS Word COM document.
elseif (!$com(SGC:Doc,$iif($SGC:Conf(2),CheckGrammar,CheckSpelling),1)) %r = Unable to check Spelling and/or Grammar of specified text.
elseif (!$com(SGC:Doc,Content,2,dispatch* SGC:Con)) %r = Unable to request corrected text from the MS Word COM document.
elseif (!$com(SGC:Con,Text,2)) %r = Unable to retrieve corrected text from the MS Word COM document.
else {
.timer -m 1 1 editbox -n $SGC:Safe($active $regsubex($com(SGC:Con).result,[\r\n]+$,))
.comclose SGC:Con
halt
}
}
:error
%r = $iif(%r,$v1,$error)
reseterror
SGC:Cleanup
echo -ag * $+($chr(2),$chr(3),04Spelling and Grammar Check,$chr(15),:) %r
}
}
on *:EXIT:SGC:Cleanup
on *:UNLOAD:SGC:Cleanup | unset %SGC:Conf

Comments

Sign in to comment.
SReject   -  Oct 17, 2012
@XPiRX I'm thinking this is due to mIRC being unicode though I haven't coded mIRC in many months.
 Respond  
XPiRX   -  Oct 16, 2012
Wow, couple of updates since I was last here. I see you implemented by grammar idea. Nice, cheers for that. I am having an issue with grammatical punctuation such a apostrophes. They end up being ’ instead of a '. Not sure why this is. Maybe office is using a font type that isn't compatible with mirc?

Edit: Using mirc 7.19, no other scripts. Office 2010.
 Respond  
Bruce1953   -  Feb 12, 2012
Please PM me the script and I will test it ASAP.
 Respond  
SReject   -  Jan 30, 2012
Bruce1953: I *THINK* I have the auto correct working. If you, or anyone else wants to test it, Just say so and I will pm you the script. (I don't want to make it public until I know it works)
 Respond  
SReject   -  Jan 30, 2012
I won't promise due to a bug with /editbox & on input, but I will try :)
 Respond  
Bruce1953   -  Jan 29, 2012
Could you please enable auto correct in the script? The spell/grammar check is fast on my Intel core 7 processor. At least make it an option like you did for grammar check. Thank you.
 Respond  
SReject   -  Jan 26, 2012
@Conscious: I fixed it so it works with both channel and queries now. :)

@Bruce1953: It's intentional to only work with shift+enter because the spell/grammar checking is slow. To change it to work with just Enter would take some work.
 Respond  
Bruce1953   -  Jan 24, 2012
The script as is does not work in Query windows, but does work in Channel windows. I tried the modification Conscios suggested and it now works in query windows too, now if I could only get it to work on a Enter instead of Shift + Enter and enable Auto Correct.
 Respond  
Conscious   -  Jan 21, 2012
I loaded it again after a while, the first time it showed up behind mIRC, then the next time(s) it was fine. Also I had to change the #,? to * to make it work, it wasn't working at all (only tried in query though)
 Respond  
Bruce1953   -  Jan 19, 2012
It took a while before it started working, but with Word 2010 and mIRC 7.22 it worked. Adding your line to a spelling script disabled it. The only thing that appears not to work is Auto Correct. I'd like to ad some words that expend to commonly used URLs "wsg" is one example that would expand to "http://www.thewebsiteguys.com". I would also like to change the command it works on from shift+enter to just enter.
 Respond  
SReject   -  Jan 08, 2012
@Trixster: I've been trying to figure that out for some time. I don't think it's possible with MS Word's API.
 Respond  
Trixster   -  Jan 07, 2012
It would be nice that when you press cancel it didn't enter the text anyway and would blank it and send nothing. Other then that really really good thanks.
 Respond  
SReject   -  Dec 27, 2011
Just updated this thing to include Grammar Checking, WOOTS!

I think I've finally tracked down and fixed the bug where the correction dialog would open behind mIRC. If not let me know. :)
 Respond  
Rukbat   -  Oct 02, 2011
Brilliant. The way I type, I've needed this for years.

Autocap? Only if we can turn it off.
 Respond  
SReject   -  Jul 23, 2011
I was thinking about the grammar part of it all, and for the loops to jump through to incorporate it would not be worth the results. Not to mention most users don't care about their grammar as long as what they are saying is understandable; it is after all IRC. With that said, if enough users ask for it I will see what I can do :)

The freezing is something that isn't easily fixed[as of yet] due to mIRC's current COM support. The alternative would take a LARGE deal of coding, sloppy work-arounds, and the such. I have the code to get the misspelled words and their suggestions. If you'd like to try to do something with it, you can get it here: http://forum.swiftirc.net/viewtopic.php?p=226801#p226801
 Respond  
XPiRX   -  Jul 18, 2011
I tried this on Win7, Office2010, mIRC 7.19 - It worked the first time, froze miRC like it was supposed to and spell checked. The 2nd time and on I did the shift-enter, it sent the text first, popped up the spell check box (mIRC wasnt frozen) and then after correction sent the fixed sentence. So it sends two lines, the before spellcheck and then after spellcheck. Would be nice if it didnt freeze mirc and you press a different hotkey before it sends like cntrl+t or something and then you can hit enter after you have spell checked.

Other than these issues, i LOVE the script. Once these issues are ironed out, its gonna be sexy.

Edit: Oh I figured it out, I hate another spellcheck script I forgot to unload. GREAT SCRIPT !!!! Love it.

Edit2: Suggestion: Add auto capitalization and sentence ends options and possibly grammar check integration(commas and what not).
 Respond  
SReject   -  Jun 21, 2011
win7 32bit or 64b? right click mIRC in Windows' task-bar, does "On Top" have a check to the left?

Also, does it happen every time you try to use spell check?
 Respond  
Conscious   -  Jun 21, 2011
7.19
Win7
2007
No conflict.
How do I check?
 Respond  
SReject   -  Jun 21, 2011
Do you have another script with an "on Input" event in it? If so u need to add the following line as the first line to be executed in that event: if (!$inpaste && $mouse.key == 4) { halt }

And some information I need to know:
What mIRC version are you using? You will need v. 6.2 or later
What OS & version are you using? You will need Win2000 or later
What MS Word version are you using? You will need MS Word 2003 or later
What kind of scripts do you have loaded? There might be a conflict between my script and those
Do you have your mIRC client set to OnTop? This will cause the box to appear behind mIRC.
 Respond  
Conscious   -  Jun 21, 2011
If you press "cancel" it sends the message twice.

Still appears behind mIRC, I have to minimise mIRC for it to show up (the first use.. odd, didn't do it just then xD)
 Respond  
Jethro   -  Jun 20, 2011
Nice. You've earned kudos from me and one more point has been added.
 Respond  
SReject   -  Jun 20, 2011
You didn't. The reason I had it the way I did was so I wouldn't have the script doing the same things over and over and over from within the if-then-else. But I got around that[as you can see], cleaned up the code, and possibly fixed Conscious' issue. :)
 Respond  
Jethro   -  Jun 20, 2011
jaytea, it was my innocent opinion, and thanks for reminding me of this matter. I did give this script a fairly high score in the first place. SRject, I hope you didn't take my comment as critical as it should be to defend your coding method. I wasn't trying to incite this thread but to comment for commentary's sake.
 Respond  
SReject   -  Jun 20, 2011
Pretaining to all the "gotos": How much easier/efficant would the code actually be if I used if-then-else and had the following within each of the if's that check for errors:

SpellCheck:Cleanup
echo -a $+($chr(2),$chr(3),04SpellCheck,$chr(15),:) The Error message here.....
return $1-
 Respond  
jaytea   -  Jun 20, 2011

Quote

Quote

This dialog WILL freeze mIRC until it is closed(YOU HAVE BEEN WARNED!).

Aren't you gonna address this issue at all? If you do work out the freezing issue, I'll increase it to 9. :P


you're overreacting to this issue, which is a shame because no one would have said anything about it if SReject hadn't added such a grave warning ;P $? and $input() both exhibit the same mIRC-hanging behaviour, and no one ever complains about them. it's even easy to replicate $input() in most cases by creating a custom modeless dialog which doesn't cause mIRC to hang. but since it appears that the overall method used here is not compatible with the feature of mIRC that would prevent the hanging ($comcall), it is not nearly as straight forward to change.

remember too, this isn't a script that can just execute at any given time, when the user is afk or otherwise. the script can only be activated when a piece of text is input by a user who knows what they're doing (shift+enter), and i wouldn't expect them to sit and stare at the screen blankly for 5 minutes while their client pings off the server, just as i wouldn't expect that of users of scripts that use $? or $input().

Quote

I haven't tried this script yet, but hopefully you can take some time to make it even better than it is, hence the repetitive goto overkill, which seems to be rather redundant.


look at Example Script #1 in /help $com. the script is perfectly readable the way it is, and i don't think modifying it to use a string of elseifs would serve to make it substantially better.

 Respond  
SReject   -  Jun 20, 2011
A few more questions Conscious:
What mIRC version are you using?
What OS & version are you using?
What MS Word version are you using?
What kind of scripts do you have loaded?

If you try to use it and that happens again, before I can figure out how the dialog ended up under mIRC, instead of killing mIRC, open your task Manager and kill WINWORD.exe
 Respond  
SReject   -  Jun 20, 2011
@Conscious: underneath as in mIRC was infront of the dialog?

@Jethro_, I do plan to address this issue. I wrote this about two weeks back, and was told that people have been looking for an mSL spellcheck. I'm currently working on getting and iliterating through the GetSpellingSuggestions collection. Once figured out I plan to create an mSL dialog/picwin for it :)

as I work through it, this thread will probably get updated: http://forum.swiftirc.net/viewtopic.php?f=34&t=24945
 Respond  
Jethro   -  Jun 20, 2011
I've heard such idea of using COM in conjunction with MS Word's inbuilt spell checker, and now I've seen it. Nice going, SReject. 1+ like and 8 points.

Quote

This dialog WILL freeze mIRC until it is closed(YOU HAVE BEEN WARNED!).
Aren't you gonna address this issue at all? If you do work out the freezing issue, I'll increase it to 9. :P

I haven't tried this script yet, but hopefully you can take some time to make it even better than it is, hence the repetitive goto overkill, which seems to be rather redundant.

P.S. I see we've got a member above who has a problem getting your snippet to work.
 Respond  
Conscious   -  Jun 20, 2011
>.< The spellcheck appeared underneath mIRC, So I just had a frozen mirc and no thingo >.>
 Respond  
blackvenomm666   -  Jun 20, 2011
havent tested it but it looks good to me and this is a pretty cool snippet i dont have word on the computer hence the me not testing it +like
 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.