donnyh13 Posted December 20, 2023 Share Posted December 20, 2023 (edited) Greetings all, While I am working with various projects along the way I often hit a reoccurring frustration of needing to know if I spelled a comment or string correctly, and have often needed to copy my word into a document to spellcheck it and then correct as needed, which feels much like a waste of time. I have finally decided to solve my problem by utilizing Libre Office. After running across a post by GMK, demonstrating his Spell Checker script, I thought I would make my own version. And now that I have this working satisfactorily, I thought I would share it in case others are sitting in a similar spot as I was. Note: this add-on is not recommended for those new to modifying their Scite User Properties, or are unaware of where their App Data Scite installation is. This utilizes the Libre Office spell checking engine for use in Scite4Autoit so you can check the spelling of words on the fly using a shortcut combo, and offering suggestions if the word is misspelled. This Add-on also allows you to spellcheck an entire script or a selected range's Strings, Comments, and comment blocks for misspelled words, marking them for review. The Script Spell checker skips words with the following in them: . $ # @ _ : / \ I have added the ability to spell check in other, and/or multiple, languages, though I am limited to my ability to test this, English being my only language. Requirements: Full installation of Scite4AutoIt LibreOffice (Installed version only, portable will not work.) Desired Spell Checking language installed in Libre Office. Installation To "Install" this Add-On for Scite4AutoIt, do the following. Navigate to %LocalAppData%\Local\AutoIt v3\SciTE (You can copy and paste this into Start search box and push enter) Copy the "Scite4AutoIt_LO_SpellChecker" folder into this directory. Do one of the following, depending on if you already have custom lua scripts present in PersonalTools.lua or not. If you do not have custom scripts present in PersonalTools.lua, find in this same directory the file PersonalTools.lua, and rename it to PersonalTools.lua.old Copy the PersonalTools.lua file from the Add-On folder to the %LocalAppData%\Local\AutoIt v3\SciTE directory. If you do have custom scripts present in PersonalTools.lua, Open the PersonalTools.lua file in the Add-On folder and copy everything in the file below the following entry, ------------------------------------------------------------------------------- -- required line ... do not remove PersonalTools = EventClass:new(Common) ------------------------------------------------------------------------------- Paste the contents into the end of the PersonalTools.lua file found in the %LocalAppData%\Local\AutoIt v3\SciTE directory. Open your SciTEUser.properties file, (go to Scite editor and Select "Options" in the toolbar, Select "Open User Options File".) Copy and paste the following into the SciTEUser.properties File. (If you have previous custom Lua Scripts, you may need to modify the command numbering.) #~ Single Word Spell-Check lua Script command.name.45.$(au3)=Sp-Check Current Word command.mode.45.$(au3)=subsystem:lua,savebefore:no command.shortcut.45.$(au3)=Ctrl+Shift+F command.45.$(au3)=InvokeTool PersonalTools.SingleWordCheck #~ #~ Entire Script Spell-Check lua Script command.name.46.$(au3)=Sp-Check Entire Script command.mode.46.$(au3)=subsystem:lua,savebefore:no command.shortcut.46.$(au3)=Ctrl+Shift+G command.46.$(au3)=InvokeTool PersonalTools.CheckScript #~ #~ Clear Spell Checking Marking lua Script command.name.47.$(au3)=Sp-Check Clear command.mode.47.$(au3)=subsystem:lua,savebefore:no command.shortcut.47.$(au3)=Ctrl+Shift+H command.47.$(au3)=InvokeTool PersonalTools.ClearSpChk #~ *You may modify any Shortcut key combinations as necessary.* Restart Scite Ignored Words You can add words to ignore in the file "Scite4AutoIt_LO_IgnoredWords.ini" that you placed in "%LocalAppData%\Local\AutoIt v3\SciTE\Scite4AutoIt_LO_SpellChecker". ONLY one word per line. No lone punctuation characters please. Words are Case Sensitive. Properties - You may set the following properties by pasting the property values in your "User Options" File (from Scite's toolbar go to, Options->Open User Options File), and modifying the value after "=" ###Language and Country### S4A.SpellCheck.Language=en S4A.SpellCheck.Country=US Language code must be a LOWER CASE two or three character ISO 639 Language Code. You can find a list of these codes online, such as https://iso639-3.sil.org/code_tables/639/data Country code must be an UPPER CASE two character ISO 3166 Country Code. You can find a list of these codes online, such as https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2 YOU MUST HAVE the desired Language installed in Libre Office already for this to work. Default is Language: en, Country: US Also accepts multiple value pairs separated by a semicolon, such as: S4A.SpellCheck.Language=en;pl S4A.SpellCheck.Country=US;PL Pairs must be equal between Language and Country. And each column must be a valid Language and Country pair. i.e. (en US), (pl PL). The first language/country pair listed is considered your primary language and any words will be checked by it first. Duplicate suggestions are automatically removed, when multiple languages are used. ###Misspelled Word Highlighting### S4A.SpellCheck.Highlight=0xFF00FF Modify the misspelled word highlighting. Must be 8 characters long, and contain only a-f, x, and 0-9 and begin with 0x. Highlighting color code is Hex color code of B(lue) G(reen) R(ed) (Not RGB). One way you can obtain this value is by using the value given from the example script provided with AutoIt function _ChooseColor, and selecting the BGR button. Default is 0xFF00FF ###Maximum Suggestions### S4A.SpellCheck.MaxSuggestions=10 Set the maximum words returned per language/country pairs. Must contain only digits, and be greater than 0. Default is 10. ###Markers Off### S4A.SpellCheck.UseMarkers=y - Set to "n" (no quotes) to skip adding a marker in the left hand margin of Scite on each line containing a spelling error. Notes This function uses the following Styles for Scite functions. UserList Type: 18 Indicator Style: 10 Marker Number: 18 This has been developed using the Scite4AutoIt Beta Version 5, currently being developed by Jos, I tried it in the standard Scite4A release V. 4 and it seems to function properly, except, in the standard Scite release a cmd window appears for a second or two. I seem to be unable to get around this. However it does not appear in the beta release. I would be happy to hear any suggestions, though I can’t promise prompt help or replies, but will do what I can. I am currently still working on another project, so anything done to this will be sporadic and delayed. v0.1.1 Scite4AutoIt_LibreOffice_SpellChecker.zip Edited May 1 by donnyh13 Update Danyfirex and argumentum 2 LibreOffice UDF ; Scite4AutoIt Spell-Checker Using LibreOffice Spoiler "Life is chiefly made up, not of great sacrifices and wonderful achievements, but of little things. It is oftenest through the little things which seem so unworthy of notice that great good or evil is brought into our lives. It is through our failure to endure the tests that come to us in little things, that the habits are molded, the character misshaped; and when the greater tests come, they find us unready. Only by acting upon principle in the tests of daily life can we acquire power to stand firm and faithful in the most dangerous and most difficult positions." Link to comment Share on other sites More sharing options...
donnyh13 Posted April 26 Author Share Posted April 26 New Version -- v0.1.0 ** Added ** Spell Checker now can mark lines with misspelled words using a Margin marker also. Single Word check now will check the currently selected word. Script check now will be restrained to a selected portion if a selection exists. ClearSpChk function will now clear only a selection if one exists. ClearSpChk function now also clears the new Margin Markers also. Selected words that are single word spell checked can also be replaced using the drop down. ** Fixed ** Some apostrophied words not being correctly selected, such as "I'll". Some markings incorrectly included as part of the word at the beginning or end, such as dashes, quotations etc. Two if blocks in the program were incorrectly testing for nill, instead of nil. ** Changed ** Rewrote the word recognition method to work better and quicker. Seconds read out at end of Script is now maximum 4 characters long. Words to spell check are now directly written to the file, instead of to a table and then to a file, saving several milliseconds. argumentum 1 LibreOffice UDF ; Scite4AutoIt Spell-Checker Using LibreOffice Spoiler "Life is chiefly made up, not of great sacrifices and wonderful achievements, but of little things. It is oftenest through the little things which seem so unworthy of notice that great good or evil is brought into our lives. It is through our failure to endure the tests that come to us in little things, that the habits are molded, the character misshaped; and when the greater tests come, they find us unready. Only by acting upon principle in the tests of daily life can we acquire power to stand firm and faithful in the most dangerous and most difficult positions." Link to comment Share on other sites More sharing options...
donnyh13 Posted May 1 Author Share Posted May 1 Bug Fix Made a correction to the word replacement when a user selected the new word. I accidentally broke it in the last release. Sorry. Danyfirex and argumentum 2 LibreOffice UDF ; Scite4AutoIt Spell-Checker Using LibreOffice Spoiler "Life is chiefly made up, not of great sacrifices and wonderful achievements, but of little things. It is oftenest through the little things which seem so unworthy of notice that great good or evil is brought into our lives. It is through our failure to endure the tests that come to us in little things, that the habits are molded, the character misshaped; and when the greater tests come, they find us unready. Only by acting upon principle in the tests of daily life can we acquire power to stand firm and faithful in the most dangerous and most difficult positions." Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now