I am trying to send a simple "CTRL+C"
stroke to another window.
The idea is to grab text from IE/FF/Chrome/IE/Excel/Word
. Anyway, I have tried to use SendKeys.Send()
and SendKeys.SendWait()
and InputSimulator's Keyboard.KeyPress()
. None of them throw exceptions (Well SendKeys.Send()
, but that's expected) but none of them actually send anything.
I have tried to just send letter presses and nothing happens. I will include code snippets to see if maybe I am doing something real dense but I worry its a Win10 isolation thing. Has anyone had luck sending keystrokes outside of their own app in Win10 yet?
Sendkeys:
public void DoItDamnYou()
{
SendKeys.SendWait("C");
MessageBox.Show("Press SHOULD have happened");
}
InputSimulator
public void DoItDamnYouNow()
{
InputSimulator input = new InputSimulator();
input.Keyboard.KeyPress(WindowsInput.Native.VirtualKeyCode.VK_D);
MessageBox.Show("Now we are in the wrapper.");
}
If anyone has any ideas I would greatly appreciate them.
Thanks
Seems Sendkeys are disabled in Windows 10. In Windows 8.1 , Diasbling UAC in Registry I can use SendKeys to Windows Calculator as usual. In Windows 10, disabling the UAC in Restry the Calculator will not launch at all. Enabling the UAC the Calculator launches, but is not accepting any Sendkeys Command, but is accepting the Ctrl+V and Ctrl+C (read and copy to Clipboard) issued from directly from Keyboard.
来源:https://stackoverflow.com/questions/31846863/sending-key-strokes-with-c-sharp-in-win10-outside-of-app