[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_RMENU = 0xA5;
keybd_event(VK_SHIFT, 0, KEYEVENTF_EXTENDEDKEY, 0);
keybd_event(VK_Q, 0, KEYEVENTF_EXTENDEDKEY, 0);
keybd_event(VK_Q, 0, KEYEVENTF_KEYUP, 0);
keybd_event(VK_SHIFT, 0, KEYEVENTF_KEYUP, 0);
我根据需要得到了大写字母Q,但问题是,“转变”很难。
之后的所有信都是资本。获得小写的唯一方法是更改大写锁定。我该如何解决这个问题?
提前致谢
答案 0 :(得分:2)
我相信Cody Gray为您解决了问题。只需将您的P / Invoke呼叫替换为:
keybd_event(VK_SHIFT, 0, 0, 0);
keybd_event(VK_Q, 0, 0, 0);
keybd_event(VK_Q, 0, KEYEVENTF_KEYUP, 0);
keybd_event(VK_SHIFT, 0, KEYEVENTF_KEYUP, 0);