C语音键盘钩子和用法 模拟键盘

#include<windows.h>

void main()
{
 /*
 函数原型
 VOID keybd_event(
 BYTE bVk,
 BYTE bScan,
 DWORD dwFlags,
 DWORD dwExtraInfo
 );*/
 
 //参数1键盘代表的16进制Virtual Key Codes(Compact 2013)有帮助
 //VK_LWIN
 // 0x5B
 // Left Windows key on a Microsoft Natural Keyboard.
 //
 //keybd_event(0x5b, 0, 0, 0); //其他默认救行
 //keybd_event(0x5b, 0, 2, 0); //这个代表松开按键

 //显示桌面
 //keybd_event(0x5b, 0, 0, 0);
 //keybd_event(‘D‘, 0, 0, 0);
 //keybd_event(‘D‘, 0, 2, 0);
 //keybd_event(0x5b, 0,2, 0);.

 //打开记事本
 keybd_event(0x5b, 0, 0, 0);
 keybd_event(‘R‘, 0, 0, 0);
 keybd_event(‘R‘, 0, 2, 0);
 keybd_event(0x5b, 0,2, 0);
 Sleep(1000);
 keybd_event(‘N‘, 0, 0, 0);
 keybd_event(‘N‘, 0, 2, 0);
 keybd_event(‘O‘, 0, 0, 0);
 keybd_event(‘O‘, 0, 2, 0);
 keybd_event(‘T‘, 0, 0, 0);
 keybd_event(‘T‘, 0, 2, 0);
 keybd_event(‘E‘, 0,0, 0);
 keybd_event(‘E‘, 0, 2, 0);
 keybd_event(‘P‘, 0, 0, 0);
 keybd_event(‘P‘, 0, 2, 0);
 keybd_event(‘A‘, 0, 0, 0);
 keybd_event(‘A‘, 0, 2, 0);
 keybd_event(‘D‘, 0,0, 0);
 keybd_event(‘D‘, 0, 2, 0);
 Sleep(200);
 keybd_event(0x0D, 0, 0, 0);
 keybd_event(0x0D, 0, 2, 0);
 Sleep(200);
 keybd_event(0x14, 0, 0, 0);
 keybd_event(0x14, 0, 2, 0);
 
 keybd_event(‘H‘, 0, 0, 0);
 keybd_event(‘H‘, 0, 2, 0);
 keybd_event(‘E‘, 0, 0, 0);
 keybd_event(‘E‘, 0, 2, 0);
 Sleep(200);
 keybd_event(‘L‘, 0, 0, 0);
 keybd_event(‘L‘, 0, 2, 0);
 Sleep(200);
 keybd_event(‘L‘, 0, 0, 0);
 keybd_event(‘L‘, 0, 2, 0);
 Sleep(200);
 keybd_event(‘O‘, 0, 0, 0);
 keybd_event(‘O‘, 0, 2, 0);
 Sleep(200);
 keybd_event(‘W‘, 0, 0, 0);
 keybd_event(‘W‘, 0, 2, 0);
 Sleep(200);
 keybd_event(‘O‘, 0, 0, 0);
 keybd_event(‘O‘, 0, 2, 0);
 Sleep(200);
 keybd_event(‘R‘, 0, 0, 0);
 keybd_event(‘R‘, 0, 2, 0);
 Sleep(200);
 keybd_event(‘D‘, 0, 0, 0);
 keybd_event(‘D‘, 0, 2, 0);
 Sleep(200);
 keybd_event(0x0D, 0, 0, 0);
 keybd_event(0x0D, 0, 2, 0);
}

感觉好的给个评论和赞 谢谢

Virtual Key Codes (Compact 2013)

Send
Feedback on this topic to Microsoft.


View
this topic online in your default
browser.

3/28/2014

The following table shows the symbolic constant names, hexadecimal values,
and keyboard equivalents for the virtual key codes used by the Windows Embedded
Compact operating system. The codes are listed in numeric order. To create a hot
key, you can combine any of the codes with a modifier key.

Virtual key codes


Symbolic constant


Hexadecimal value


Mouse or keyboard equivalent


VK_LBUTTON


0x01


Left mouse button.


VK_RBUTTON


0x02


Right mouse button.


VK_CANCEL


0x03


Control-break processing.


VK_MBUTTON


0x04


Middle mouse button on a three-button mouse.


0x05-0x07


Undefined.


VK_BACK


0x08


BACKSPACE key.


VK_TAB


0x09


TAB key.


0x0A-0x0B


Undefined.


VK_CLEAR


0x0C


CLEAR key.


VK_RETURN


0x0D


ENTER key.


0x0E-0x0F


Undefined.


VK_SHIFT


0x10


SHIFT key.


VK_CONTROL


0x11


CTRL key.


VK_MENU


0x12


ALT key.


VK_PAUSE


0x13


PAUSE key.


VK_CAPITAL


0x14


CAPS LOCK key.


0x15-0x19


Reserved for Kanji systems.


0x1A


Undefined.


VK_ESCAPE


0x1B


ESC key.


0x1C-0x1F


Reserved for Kanji systems.


VK_SPACE


0x20


SPACEBAR.


VK_PRIOR


0x21


PAGE UP key.


VK_NEXT


0x22


PAGE DOWN key.


VK_END


0x23


END key.


VK_HOME


0x24


HOME key.


VK_LEFT


0x25


LEFT ARROW key.


VK_UP


0x26


UP ARROW key.


VK_RIGHT


0x27


RIGHT ARROW key.


VK_DOWN


0x28


DOWN ARROW key.


VK_SELECT


0x29


SELECT key.


0x2A


Specific to OEM.


VK_EXECUTE


0x2B


EXECUTE key.


VK_SNAPSHOT


0x2C


PRINT SCREEN key.


VK_INSERT


0x2D


INS key.


VK_DELETE


0x2E


DEL key.


VK_HELP


0x2F


HELP key.


0x3A-0x40


Undefined.


VK_LWIN


0x5B


Left Windows key on a Microsoft Natural Keyboard.


VK_RWIN


0x5C


Right Windows key on a Microsoft Natural Keyboard.


VK_APPS


0x5D


Applications key on a Microsoft Natural Keyboard.


0x5E-0x5F


Undefined.


VK_NUMPAD0


0x60


Numeric keypad 0 key.


VK_NUMPAD1


0x61


Numeric keypad 1 key.


VK_NUMPAD2


0x62


Numeric keypad 2 key.


VK_NUMPAD3


0x63


Numeric keypad 3 key.


VK_NUMPAD4


0x64


Numeric keypad 4 key.


VK_NUMPAD5


0x65


Numeric keypad 5 key.


VK_NUMPAD6


0x66


Numeric keypad 6 key.


VK_NUMPAD7


0x67


Numeric keypad 7 key.


VK_NUMPAD8


0x68


Numeric keypad 8 key.


VK_NUMPAD9


0x69


Numeric keypad 9 key.


VK_MULTIPLY


0x6A


Multiply key.


VK_ADD


0x6B


Add key.


VK_SEPARATOR


0x6C


Separator key.


VK_SUBTRACT


0x6D


Subtract key.


VK_DECIMAL


0x6E


Decimal key.


VK_DIVIDE


0x6F


Divide key.


VK_F1


0x70


F1 key.


VK_F2


0x71


F2 key.


VK_F3


0x72


F3 key.


VK_F4


0x73


F4 key.


VK_F5


0x74


F5 key.


VK_F6


0x75


F6 key.


VK_F7


0x76


F7 key.


VK_F8


0x77


F8 key.


VK_F9


0x78


F9 key.


VK_F10


0x79


F10 key.


VK_F11


0x7A


F11 key.


VK_F12


0x7B


F12 key.


VK_F13


0x7C


F13 key.


VK_F14


0x7D


F14 key.


VK_F15


0x7E


F15 key.


VK_F16


0x7F


F16 key.


VK_F17


0x80


F17 key.


VK_F18


0x81


F18 key.


VK_F19


0x82


F19 key.


VK_F20


0x83


F20 key.


VK_F21


0x84


F21 key.


VK_F22


0x85


F22 key.


VK_F23


0x86


F23 key.


VK_F24


0x87


F24 key.


0x88-0x8F


Unassigned.


VK_NUMLOCK


0x90


NUM LOCK key.


VK_SCROLL


0x91


SCROLL LOCK key.


VK_LSHIFT


0xA0


Left SHIFT.


VK_RSHIFT


0xA1


Right SHIFT.


VK_LCONTROL


0xA2


Left CTRL.


VK_RCONTROL


0xA3


Right CTRL.


VK_LMENU


0xA4


Left ALT.


VK_RMENU


0xA5


Right ALT.


0xBA-0xC0


Specific to OEM; reserved. See following tables.


0xC1-0xDA


Unassigned.


0xDB-0xDE


Specific to OEM; reserved. See following tables.


VK_OFF


0xDF


Used to power the device on and off. No keyboard equivalent.


0xE1-0xE4


Specific to OEM.


0xE5


Unassigned.


0xE6


Specific to OEM.


VK_PACKET


0xE7


Used to pass Unicode characters as if they were keystrokes. If VK_PACKET is
used with SendInput, then the Unicode character to be delivered should be placed
into the lower 16 bits of the scan code. If a keyboard message is removed from
the message queue and the virtual key is VK_PACKET, then the Unicode character
will be the upper 16 bits of the lparam.


0xE8


Unassigned.


0xE9-0xF5


Specific to OEM.


VK_ATTN


0xF6


ATTN key.


VK_CRSEL


0xF7


CRSEL key.


VK_EXSEL


0xF8


EXSEL key.


VK_EREOF


0xF9


Erase EOF key.


VK_PLAY


0xFA


PLAY key.


VK_ZOOM


0xFB


ZOOM key.


VK_NONAME


0xFC


Reserved.


VK_PA1


0xFD


PA1 key.


VK_OEM_CLEAR


0xFE


CLEAR key.

OEMs should make special note of the VK key ranges reserved for specific OEM
use: 2A, DB-E4, E6, and E9-F5.

In addition to the virtual key assignments in the previous table, Microsoft
has assigned the following specific OEM virtual keys.


Symbolic constant


Hexadecimal value


Mouse or keyboard equivalent


VK_OEM_SCROLL


0x91


None.


VK_OEM_1


0xBA


";:" for US.


VK_OEM_PLUS


0xBB


"+" any country/region.


VK_OEM_COMMA


0xBC


"," any country/region.


VK_OEM_MINUS


0xBD


"-" any country/region.


VK_OEM_PERIOD


0xBE


"." any country/region.


VK_OEM_2


0xBF


"/?" for US.


VK_OEM_3


0xC0


"`~" for US.


VK_OEM_4


0xDB


"[{" for US.


VK_OEM_5


0xDC


"\|" for US.


VK_OEM_6


0xDD


"]}" for US


VK_OEM_7


0xDE


"‘"" for US.


VK_OEM_8


0xDF


None. By default, this is equivalent to VK_OFF.


VK_OEM_AX


0xE1


AX key on Japanese AX keyboard.


VK_OEM_102


0xE2


"<>" or "\|" on RT 102-key keyboard.

For East Asian Input Method Editors (IMEs), the following additional virtual
keyboard definitions must be observed.


Symbolic constant


Hexadecimal value


Description


VK_DBE_ALPHANUMERIC


0x0f0


Changes the mode to alphanumeric.


VK_DBE_KATAKANA


0x0f1


Changes the mode to Katakana.


VK_DBE_HIRAGANA


0x0f2


Changes the mode to Hiragana.


VK_DBE_SBCSCHAR


0x0f3


Changes the mode to single-byte characters.


VK_DBE_DBCSCHAR


0x0f4


Changes the mode to double-byte characters.


VK_DBE_ROMAN


0x0f5


Changes the mode to Roman characters.


VK_DBE_NOROMAN


0x0f6


Changes the mode to non-Roman characters.


VK_DBE_ENTERWORDREGISTERMODE


0x0f7


Activates the word registration dialog box.


VK_DBE_ENTERIMECONFIGMODE


0x0f8


Activates a dialog box for setting up an IME environment.


VK_DBE_FLUSHSTRING


0x0f9


Deletes the undetermined string without determining it.


VK_DBE_CODEINPUT


0x0fa


Changes the mode to code input.


VK_DBE_NOCODEINPUT


0x0fb


Changes the mode to no-code input.

OEMs should not use the unassigned portions of the virtual key (VK) mapping
tables. If manufacturers require additional VK mappings, they should reuse some
of the current manufacturer-specific and vendor-specific assignments.

时间: 2025-01-07 06:30:31

C语音键盘钩子和用法 模拟键盘的相关文章

VB模拟键盘输入的N种方法

VB模拟键盘输入的N种方法http://bbs.csdn.net/topics/90509805hd378发表于: 2006-12-24 14:35:39用VB模拟键盘事件的N种方法 键盘是我们使用计算机的一个很重要的输入设备了,即使在鼠标大行其道的今天,很多程序依然离不开键盘来操作.但是有时候,一些重复性的,很繁琐的键盘操作总会让人疲惫,于是就有了用程序来代替人们按键的方法,这样可以把很多重复性的键盘操作交给程序来模拟,省了很多精力,按键精灵就是这样的一个软件.那么我们怎样才能用VB来写一个程

键盘钩子 用来截屏

.点击开始按钮 .a窗体隐藏,b窗体显示 scsysrq截图 .需要在桌面创建bc文件夹. 总的思路就是用钩子获取键盘信息 然后进行截图的线程控制 using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Diagnostics;using System.Drawing;using System.Linq;using System.Runtime

C#鼠标键盘钩子

using System;using System.Collections.Generic; using System.Reflection; using System.Runtime.InteropServices; using System.Text; using System.Windows.Forms; namespace ICS.Common { /// <summary> /// 这个类可以让你得到一个在运行中程序的所有键盘或鼠标事件 /// 并且引发一个带KeyEventArgs

使用raw input 代替全局键盘钩子

//关于raw input 请查看msdn https://msdn.microsoft.com/en-us/library/windows/desktop/ms645536%28v=vs.85%29.aspx //效率 比 键盘钩子高太多 ,但是BCB 中无法识别 RAWINPUTDEVICE 结构 和RAW相关的函数 // rawinput4.cpp : 定义应用程序的入口点. // #include "stdafx.h" #include "rawinput4.h&qu

C# 模拟键盘操作--SendKey(),SendKeys()

模拟键盘输入就是使用以下2个语法实现的.SendKeys.Send(string keys);  //模拟汉字(文本)输入SendKeys.SendWait(string keys); //模拟按键输入 先了解一下2个语法的用法吧! 稍后贴出代码看看大家能不能看懂哦/... (1)每个按键由一个或多个字符表示.为了指定单一键盘字符,必须按字符本身的键.例如,为了表示字母 A,可以用 "A" 作为 string.为了表示多个字符,就必须在字符后面直接加上另一个字符.例如,要表示 A.B

用Delphi模拟键盘输入

在Windows大行其道的今天,windows界面程序受到广大用户的欢迎.对这些程序的操作不外乎两种,键盘输入控制和鼠标输入控制.有时,对于繁杂的,或重复性的操作,我们能否通过编制程序来代替手工输入,而用程序来模拟键盘及鼠标的输入呢?答案是肯定的.这主要是通过两个API函数来实现的. 下面以Delphi为例来介绍一下如何实现这两个功能.模拟键盘我们用Keybd_event这个api函数,模拟鼠标按键用mouse_event函数.大家不用担心,在delphi里调用api函数是很方便的事. 先介绍一

C#键盘钩子 鼠标钩子

最新对C#模拟键盘按键,鼠标操作产生了兴趣.特从网上收集了一些常用的API用来调用键盘,鼠标操作. class Win32API { #region DLL导入 /// <summary> /// 用于设置窗口 /// </summary> /// <param name="hWnd"></param> /// <param name="hWndInsertAfter"></param> ///

输入法切换小程序(js模拟键盘按键输入成功版)

花了半天时间写了个小程序,基本满足最初需求(但目前只支持IE浏览器). 需求: 在输入汉字的时候没有切换出中文输入法而导致输入了拼音,我们要做的是:将输入的拼音删除并且切换出中文输入法,重新自动在输入法中打出相应的字母. 我的电脑上默认只有两个输入法,中文输入法和美式键盘,所以模拟出”ctrl+空格键“即可在两个输入法之间进行切换. 做的过程和想法: 最初想的是使用网页配合js来做,毕竟界面好做一些.首先想到的就是用js来模拟键盘的输入,想法很好,但是却很难,主要是因为浏览器为了考虑安全性,所以

钩子编程(HOOK) 安装进程内键盘钩子

作者 : 卿笃军 系统钩子:钩子可以监视系统或进程中的各种事件消息,截获发往目标窗口的消息并进行处理.这样,我们就可以在系统中安装自定义的钩子,监视系统中特定事件的发生,完成特定的功能,比如截获键盘.鼠标的输入,屏幕取词,日志监视等等. 下面演示如何安装进程内键盘钩子: 第一步:打开VC6.0,创建一个基于对话框的MFC应用程序. 第二步:在BOOL CHookDlg::OnInitDialog()函数上面编写如下代码:(注意是在上面编写,不是在OnInitDialog()里面) HHOOK g