我有一个小程序,使用该系统模拟ctr+ c&ctr+ v(复制和粘贴)事件keybd_event.问题是程序运行后,计算机继续ctrl按下键,然后 - 如果我键入a它选择整个文档,如果我滚动鼠标滚轮它会改变文本方面等.它不仅发生在Visual Studio编辑器中,但在程序以Word等运行时打开的任何其他程序.这是我的代码:
//The system keyboard event.
[System.Runtime.InteropServices.DllImport("user32.dll", SetLastError = true)]
static extern void keybd_event(byte bVk, byte bScan, int dwFlags, int dwExtraInfo);
public const int KEYEVENTF_EXTENDEDKEY = 0x0001; //Key down flag
public const int KEYEVENTF_KEYUP = 0x0002; //Key up flag
public const int VK_LCONTROL = 0xA2; //Left Control key code
public const int C = 0x43; // C key code
public const int V = …Run Code Online (Sandbox Code Playgroud)