Yanıt How to get cursor position?

  • 01 Mayıs 2012 Salı 12:05
     
     

    Hello!

    I have developed a VSTO using visual studio 2010 for office word. The version of Word is 2010.
    I want to get keybord position, the following.  How to get keybord position.

    ( C# 4.0 / Word 2010/ Visual Studio 2010 )


    thanks in advance.






    • Düzenleyen vsmmma 01 Mayıs 2012 Salı 15:08
    •  

Tüm Yanıtlar

  • 01 Mayıs 2012 Salı 16:48
     
     

    The Word Primary Interop Assemblies (PIAs) don't provide for that....hopefully someone can still help you, though.

    Good diagram. Helpful, also, is the word 'caret' (in terms of Word programming this is also referred to with the terms 'insertion point' and 'selection').

  • 01 Mayıs 2012 Salı 21:06
    Moderatör
     
     Önerilen Yanıt

    Hi Vsmmma

    The only thing the Word object model offers is the ActiveWindow.GetPoint method for the Range object. It's not 100% accurate but might help you...


    Cindy Meister, VSTO/Word MVP


  • 01 Mayıs 2012 Salı 21:17
     
     
    Do ranges have a GetPoint method (or a 'Windows' property)? It's not listed on MSDN (as a range member) and my VS intellisense won't pick it up.

    • Düzenleyen JosephFox 01 Mayıs 2012 Salı 21:19
    • Düzenleyen JosephFox 01 Mayıs 2012 Salı 21:19
    •  
  • 02 Mayıs 2012 Çarşamba 02:37
     
     Yanıt Kod İçerir

    Thank you for your help, JosephFox, Cindy Meister.
    I could succeed.


    Thank you very much.

    my code ...

                    Word.Range r = Globals.ThisAddIn.Application.Selection.Range;
    
                    int left, top, width, height;
                    Globals.ThisAddIn.Application.ActiveWindow.GetPoint(out left, out top, out width, out height, r);
    


    • Yanıt Olarak Öneren JosephFox 02 Mayıs 2012 Çarşamba 14:06
    • Yanıt Olarak İşaretleyen Tom_Xu_WXModerator 07 Mayıs 2012 Pazartesi 07:28
    •  
  • 02 Mayıs 2012 Çarşamba 14:06
     
     
    Ah, I see! I guess I'm a little slower than you and Cindy.
    • Düzenleyen JosephFox 02 Mayıs 2012 Çarşamba 14:07 punctuation change
    •