Wince 模拟键盘输出Ctrl+v
“Ctrl” ACSII 为17,“v” ACSII 为86
KeySends.Sends(17,86);
public class KeySends
{
/// <summary>
/// 将按键送至全局键盘缓冲区
/// </summary>
/// <param name="key">key=-1为不启动</param>
public static void SendKey(int key)
{
//const byte KEYEVENTF_SILENT = 0x0004;
if (key != -1)
{
const int KEYEVENTF_KEYUP = 0x02;
const int KEYEVENTF_KEYDOWN = 0x00;
keybd_event(key, 0, KEYEVENTF_KEYDOWN, 0);
keybd_event(key, 0, KEYEVENTF_KEYUP, 0);
}
}
/// <summary>
/// 将按键送至全局键盘缓冲区
/// </summary>
/// <param name="key1">组合键盘1</param>
/// <param name="key2">组合键盘2</param>
public static void SendKey(int key1,int key2)
{
const int KEYEVENTF_KEYUP = 0x02;
const int KEYEVENTF_KEYDOWN = 0x00;
keybd_event(key1, 0, KEYEVENTF_KEYDOWN, 0);
keybd_event(key2, 0, KEYEVENTF_KEYDOWN, 0);
keybd_event(key1, 0, KEYEVENTF_KEYUP, 0);
keybd_event(key2, 0, KEYEVENTF_KEYUP, 0);
}
/// <summary>
/// 键盘事件
/// </summary>
/// <param name="bVk">键盘值</param>
/// <param name="bScan"></param>
/// <param name="dwFlags"></param>
/// <param name="dwExtraInfo"></param>
[DllImport("coredll", SetLastError = true)]
private static extern void keybd_event(int bVk, int bScan, int dwFlags, int dwExtraInfo);
}