WPF 操作键盘
2014-07-07 11:21
253 查看
#region 打开键盘的键 const uint KEYEVENTF_EXTENDEDKEY = 0x1; const uint KEYEVENTF_KEYUP = 0x2; [DllImport("user32.dll")] static extern short GetKeyState(int nVirtKey); [DllImport("user32.dll")] static extern void keybd_event(byte bVk, byte bScan, uint dwFlags, uint dwExtraInfo); public enum VirtualKeys : byte { VK_NUMLOCK = 0x90, //数字锁定键 VK_SCROLL = 0x91, //滚动锁定 VK_CAPITAL = 0x14, //大小写锁定 VK_A = 62 } //获取key public static bool GetState(VirtualKeys Key) { return (GetKeyState((int)Key) == 1); } //设置key public static void SetState(VirtualKeys Key, bool State) { if (State != GetState(Key)) { keybd_event((byte)Key, 0x45, KEYEVENTF_EXTENDEDKEY | 0, 0); keybd_event((byte)Key, 0x45, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0); } } #endregion //打开大写键盘 调用: SetState(VirtualKeys.VK_CAPITAL, true);
相关文章推荐
- WPF 长时间无鼠标键盘操作自动回到主页
- wpf中界面获取鼠标或键盘操作
- WPF 中模拟键盘和鼠标操作
- C# WPF 中用代码模拟鼠标和键盘的操作
- C语言嵌入式系统编程修炼之五:键盘操作
- C语言嵌入式系统编程修炼之五:键盘操作
- VC模拟键盘操作
- 无鼠标单键盘操作电脑
- FIFA 06 键盘操作详细键位
- [ASP.NET]支持up,down以及pageup,pagedown,home,end,Enter键盘操作的DataGrid
- 系统挂钩捕捉键盘操作
- Win32学习笔记——键盘操作
- DELPHI中的键盘操作
- 键盘操作优势 IE7快捷键集锦
- 转载:键盘模拟鼠标(实现用键盘操作鼠标光标)(示例代码下载)
- 背熟以下文章,就能脱离鼠标,光用键盘操作了
- c#模拟鼠标键盘操作
- 摸拟键盘操作
- 用键盘模拟鼠标操作
- 键盘操作快捷键