locked
how do I tell there is a misspelled word in a group of words?

    Question

  • Suppose I have a text box with spell checker enabled.  My app would programmatically insert a sentence into the text box.  How do I programmatically tell when there is a misspelled word in a sentence?  In other words, how do I programmatically tell that a group of words have at least one word with a squiggly line under it?
    • Edited by RandyPete Friday, June 20, 2014 10:30 AM
    Friday, June 20, 2014 10:28 AM

Answers

  • Your scenario sounds like what the spell checker API was designed for.

    It's a COM interface and only provided directly for C++. The easiest way to expose it to your C# app will be to write a Windows Runtime Component in C++ which you can include and reference from C#.

    --Rob

    • Marked as answer by RandyPete Tuesday, June 24, 2014 4:31 AM
    Friday, June 20, 2014 7:50 PM
    Owner

All replies

  • Not directly. This is internal to the TextBox, but you have a few options.

    Do your own spell checking. Extract the text and call the spell checking API. This is probably easiest.

    I haven't tried it, but you may be able to use UI Automation to examine the TextBlock for the error flag. This isn't exposed directly (Windows Store apps are automation servers, not clients) but you should be able to find this by partying on the TextBoxAutomationPeer from inside the app. Check out the error flagged word in Inspect to see how it is marked for automation. You'll probably want to read the UI Automation Client Programmer's Guide as well as the Windows Runtime accessibility docs.

    --Rob

    Friday, June 20, 2014 1:10 PM
    Owner
  • There's a spell checking API?  Can you please give me a link?

    Friday, June 20, 2014 1:31 PM
  • Not easily from the system I'm on now, but if you type "spellcheck" into the search box at the top of the page you'll find it.
    Friday, June 20, 2014 1:35 PM
    Owner
  • Ok, I guess I should tell you what I need it for. Then perhaps it's easier for us to communicate.

    I just published a touch-oriented word processing app called Word Touch yesterday.  Already got several buyers.  And lo and behold the first review came back said everything looks good except there's no spell checker.

    I'm planning to put in a popup (at the push of a button) that will extract the texts (either word by word or line by line) into a textbox in the popup and then spell check that.  I need to be able to do it so when the extracted word(s) have no spelling error the loop will continue on.  If it detects a misspelled word, the loop will stop and tells the user.  Or something like that.

    Will the spell checker api be able to do that?

    Added by edit.

    Oh man, some of the older posts from 2012 says it only comes in C++.  My app, that I spent millions of hours on (not literally) is written in C# with plenty of sweats and tears.  Has the situation improved since 2012?  Meaning can C# access it nowadays?

    • Edited by RandyPete Friday, June 20, 2014 1:54 PM
    Friday, June 20, 2014 1:50 PM
  • Your scenario sounds like what the spell checker API was designed for.

    It's a COM interface and only provided directly for C++. The easiest way to expose it to your C# app will be to write a Windows Runtime Component in C++ which you can include and reference from C#.

    --Rob

    • Marked as answer by RandyPete Tuesday, June 24, 2014 4:31 AM
    Friday, June 20, 2014 7:50 PM
    Owner
  • Your scenario sounds like what the spell checker API was designed for.

    It's a COM interface and only provided directly for C++. The easiest way to expose it to your C# app will be to write a Windows Runtime Component in C++ which you can include and reference from C#.

    --Rob

    Thank you for your help.  I finally got it working!

    Friday, July 4, 2014 6:16 PM