码迷,mamicode.com
首页 > Windows程序 > 详细

C#中调用user32.dll库的keybd_Event函数,操作键盘

时间:2016-07-05 20:30:41      阅读:286      评论:0      收藏:0      [点我收藏+]

标签:

keybd_event()的函数原型是:

    void keybd_event(

         byte bVk,          //虚拟键码

         byte bScan,       //该键的硬件扫描码

         dword dwFlags   //函数操作的各个方面的一个标志位集

         dword dwExtraInfo  //与击键相关的附加的32位值

    );

其中第三个参数有三种取值:

  · 0:按下

  · 1:扩展键

  · 2:弹起

keybd_event(0x41, 0x1e, 0x0000, 0);   // 按下 a
keybd_event(0x41, 0x1e, 0x0002, 0);   // 弹起 a
keybd_event(0x42, 0x30, 0x0000, 0);   // 按下 b
keybd_event(0x42, 0x30, 0x0002, 0);   // 弹起 b
keybd_event(0x43, 0x2e, 0x0000, 0);   // 按下 c
keybd_event(0x43, 0x2e, 0x0002, 0);   // 弹起 c
keybd_event(0x43, 0x2e, 0x0000, 0);   // 按下 c
keybd_event(0x43, 0x2e, 0x0002, 0);   // 弹起 c

  

C#中调用user32.dll库的keybd_Event函数,操作键盘

标签:

原文地址:http://www.cnblogs.com/pocn/p/5644707.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!