none
Is there a way to send Key Press Events using the EnvDTE Interface to another Visual Studio Instance?

    Question

  • I am trying the automate some tasks for the Call Stack Window. I am able to get the Call stack Window of another VS Instance and activate it. Is there a way to send Key Press and Click Events using the EnvDTE Interface?
    Wednesday, January 03, 2018 4:14 PM

All replies

  • See Clicking a Button in Another Application. The language in that article is C# but there are many concepts that are relevant. It is also not for DTE windows but I assume it will work for them too.


    Sam Hobbs
    SimpleSamples.Info

    Wednesday, January 03, 2018 7:00 PM
  • I tried getting the handle using the Window caption from Spy++ . But I think the way Win10 does it is different. I was unable to get the handle even for the Calculator.
    Wednesday, January 03, 2018 11:55 PM
  • I apologize. I forgot that Microsoft is doing things differently with .Net and that means that the old way does not work. I am embarrassed.

    There are programs like Spy++ that work on windows created using XAML and/or the newer .Net way of doing things. I cannot help with that. When we look at windows created that way they are really complicated.



    Sam Hobbs
    SimpleSamples.Info

    Thursday, January 04, 2018 2:45 AM
  • Hi TaintedHermit,

    >>I am trying the automate some tasks for the Call Stack Window. I am able to get the Call stack Window of another VS Instance and activate it. Is there a way to send Key Press and Click Events using the EnvDTE Interface?

    Could you please provide more information about your project? Is it a c++ cli project?

    Maybe you could try to use Process.GetProcessesByName method to get the process instance. Then use Handle property to get the native handle of the associated process. Finally use SendKeys class to send keystrokes and keystroke combinations to the active application.

    Here is a document for you as a reference.

    https://docs.microsoft.com/en-us/dotnet/framework/winforms/how-to-simulate-mouse-and-keyboard-events-in-code

    Hope this could be help of you.

    Best Regards,

    Baron Bi


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, January 04, 2018 7:43 AM
    Moderator
  • Since you say EnvDTE I assume this is some kind of Visual Studio extension. And if this is a Visual Studio extension then the Visual Studio Integrate probably is a better forum. You should read the How to ask questions to increase your chances of an answer thread first.




    Sam Hobbs
    SimpleSamples.Info


    Thursday, January 04, 2018 8:00 AM