locked
How do I generate a backspace keystroke for a Text Service to recognize? RRS feed

  • Question

  • I have a Windows 7 pro platform. My .NET 3.5 C# application skins a keyboard using a touch screen for user input on the keyboard. Using the mouse action I can detect the key that the user is touching (mouse down). I then use this to simulate the keystroke using SendKeys.Send().

    Since I am passing keystrokes through the operating system at some level to receive them back, my application also sees real keyboard keystrokes as well.

    Additionally, I am using Text Services Framework, and specifically I am using the Pinyin text service to process phonetic input into Mandarin. I can send English letters to the text service using SendKeys.Send() and the text service handles them correctly, starting compositions, ending compositions, interacting with my text store to replace the phonetics with the selected candidate, etc.

    But I have a problem using my skinned virtual keyboard passing a backspace keystroke as "{BS}" or "{BACKSPACE}" through SendKeys.Send(). The text service does not seem to respond to this simulated keystroke during composition, though it does properly recognize a real keyboard backspace keystroke.

    Any insight or workaround would be much appreciated.


    • Edited by Greg Ofiesh Friday, September 9, 2011 1:48 AM
    Friday, September 9, 2011 1:47 AM

Answers

  • I got it to work using keybd_event() and the value 0x08.

     

    More importantly, I discovered that TSF only handles the backspace key only during composition mode. Otherwise, I have to handle it myself.

     

    @Paul - SendKeys.Send(Keys.Back) does not compile.


    • Marked as answer by Greg Ofiesh Monday, September 12, 2011 9:14 PM
    • Edited by Greg Ofiesh Monday, September 12, 2011 9:14 PM
    Monday, September 12, 2011 9:14 PM

All replies

  • Interaction.AppActivate("TARGET WINDOW TITLE");
    SendKeys.Send(Keys.Back);
    
    Does that help?

    If you want something you've never had, you need to do something you've never done.
    Sunday, September 11, 2011 6:20 AM
  • I got it to work using keybd_event() and the value 0x08.

     

    More importantly, I discovered that TSF only handles the backspace key only during composition mode. Otherwise, I have to handle it myself.

     

    @Paul - SendKeys.Send(Keys.Back) does not compile.


    • Marked as answer by Greg Ofiesh Monday, September 12, 2011 9:14 PM
    • Edited by Greg Ofiesh Monday, September 12, 2011 9:14 PM
    Monday, September 12, 2011 9:14 PM