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:
if (!$inpaste && $mouse.key == 4) { halt }
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
@SReject
it would be amazing if you could that it highlight the wrong spelled words in the chatbox
and make it when i cancel checking, it dose not automatic post it
and if you could add another hotkey beside shift+enter because i want to checkspelling before posting in irc
that would be amazing, and thanks
Holy run-on sentence batman!
I'm going to try and answer these the best I can:
Editbox Highlight: This isn't possible due to the com object not returning where in the text the incorrect word is placed
Cancel not posting: This isn't possible due to the com object not returning a value stipulating the cancel button was clicked
Hotkey Change: What (other) hotkeys would you like?
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.
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.
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
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).
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.
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.
[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[/quote]
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().
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.
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
@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
i don't think sreject using this site anymore