WPF SendKeys.SendWait()不能与Visibility = Hidden一起使用

时间:2015-03-04 21:36:34

标签: wpf visibility hidden

这一切都在标题中!

WPF 中的 System.Windows.Forms.SendKeys.SendWait()函数在可见性属性时不起作用MainWindow设置为隐藏

问题是什么以及如何解决?

1 个答案:

答案 0 :(得分:0)

使用WinAPI功能

[DllImport("user32.dll", SetLastError = true)]
public static extern void keybd_event(byte bVk, byte bScan, uint dwFlags, int dwExtraInfo);

Ctrl + V示例:

keybd_event(0x11, 0, 1 | 0, 0);//ctrl down
keybd_event(0x56, 0, 1 | 0, 0);//v down
keybd_event(0x56, 0, 1 | 2, 0);//v up
keybd_event(0x11, 0, 1 | 2, 0);//ctrl up