Simulating a keypress AND keyrelease in another application?

后端 未结 4 1419
终归单人心
终归单人心 2020-12-10 21:21

I need to interact with an external application running, and send specific keypresses & releases. I\'ve tried to use the SendKeys class, but it does only half of the job

4条回答
  •  旧巷少年郎
    2020-12-10 21:46

    You can use the WSH Scripting Shell to do this:

    var shell   = new WshShellClass();
    var missing = System.Reflection.Missing.Value;
    
    shell.SendKeys("MOO!!!", ref missing);
    

    All you need to do is add a COM reference to "Windows Scripting Host Object", version 1.0. Everything is in the namespace IWshRuntimeLibrary.

提交回复
热议问题