user-0 提问: keybd_event输入字符问题

回复:
user: user-1
content: 引用 11 楼 Ainew 的回复:[quote=引用 8 楼 CharlesSimonyi 的回复:] 密码控件需要驱动级的键盘模拟，如WinIO、DD虚拟键盘 请问这个驱动的怎么写啊，谢谢[/quote]  简单点，使用现成的winio或dd虚拟键盘就行了 自己去实现一个键盘驱动，太麻烦

user: user-2
content: 引用 8 楼 CharlesSimonyi 的回复:密码控件需要驱动级的键盘模拟，如WinIO、DD虚拟键盘 请问这个驱动的怎么写啊，谢谢

user: user-0
content: 引用 9 楼 songyachao 的回复:[quote=引用 8 楼 CharlesSimonyi 的回复:] 密码控件需要驱动级的键盘模拟，如WinIO、DD虚拟键盘  keybd_event(13,0,0,0); keybd_event(13,0,KEYEVENTF_KEYUP,0); 单个shift键可以控制输入法的状态 为啥组合键 ctr+space 或 ctr+shift 就不能控制了，好奇怪啊         keybd_event(18,0,0,0); 	keybd_event(121,0,0,0); 	keybd_event(121,0,KEYEVENTF_KEYUP,0); 	keybd_event(18,0,KEYEVENTF_KEYUP,0);[/quote] 上面写错了，改为：                         keybd_event(VK_CONTROL,0,0,0); 		        //keybd_event(13, MapVirtualKey(13, 0), 0, 0); 			//keybd_event(13, MapVirtualKey(13, 0), KEYEVENTF_KEYUP, 0); 			keybd_event(VK_SPACE,0,0,0); 			keybd_event(VK_SPACE,0,KEYEVENTF_KEYUP,0); 			keybd_event(VK_CONTROL,0,KEYEVENTF_KEYUP,0);

user: user-0
content: 引用 8 楼 CharlesSimonyi 的回复:密码控件需要驱动级的键盘模拟，如WinIO、DD虚拟键盘  keybd_event(13,0,0,0); keybd_event(13,0,KEYEVENTF_KEYUP,0); 单个shift键可以控制输入法的状态 为啥组合键 ctr+space 或 ctr+shift 就不能控制了，好奇怪啊         keybd_event(18,0,0,0); 	keybd_event(121,0,0,0); 	keybd_event(121,0,KEYEVENTF_KEYUP,0); 	keybd_event(18,0,KEYEVENTF_KEYUP,0);

user: user-1
content: 密码控件需要驱动级的键盘模拟，如WinIO、DD虚拟键盘

user: user-3
content: QQ对类似自动输入做了专门的屏蔽。

user: user-0
content: 请问密码区域支持keybd_event 吗，我 模拟 123456\t123456 在QQ上尝试，结果账号区输入123456光标移动到密码区域后没什么反应了，请问是不支持还是我的想法本来就不行

user: user-1
content: 键码表：https://msdn.microsoft.com/en-us/library/windows/desktop/dd375731(v=vs.85).aspx

user: user-1
content: 输入中文用SendInput方便点，SendInput是keybd_event的升级版。  #include <windows.h> #include <iostream> using namespace std;  void InputString(const wchar_t *str) { 	int words_num = wcslen(str); 	KEYBDINPUT *keyinput = new KEYBDINPUT[words_num]; 	memset(keyinput, 0, words_num * sizeof(KEYBDINPUT)); 	for (int i = 0; i < words_num; i++) 	{ 		keyinput[i].wScan = str[i]; 		keyinput[i].dwFlags = KEYEVENTF_UNICODE; 	} 	INPUT *input = new INPUT[words_num]; 	for (int i = 0; i < words_num; i++) 	{ 		input[i].type = INPUT_KEYBOARD; 		input[i].ki = keyinput[i]; 	} 	SendInput(words_num, input, sizeof(INPUT)); 	delete[] input; 	delete[] keyinput; }  void main() { 	::Sleep(3000); 	InputString(L"你好，我是小明"); }

user: user-0
content: KeyNote keyboard_NUM[]={ 	{0, 96, ZERO}, {1, 97, ZERO}, 	{2, 98, ZERO}, {3, 99, ZERO}, 	{4, 100, ZERO},{5, 101, ZERO}, 	{6, 102, ZERO},{7, 103, ZERO}, 	{8, 104, ZERO},{9, 105, ZERO} }; void CMainFrame::decodeGBK( unsigned char* data_word) { 	unsigned short datavalue=((data_word[0] << 8) | data_word[1]); 	char numstr[10]; 	int numL,i,report_i; 	unsigned char report[8] = {0}; 	report_i=0; 	numL=sprintf(numstr,"%d",datavalue);  	keybd_event(18,0,0,0); 	for(i=0;i<numL;i++) 	{ 		keybd_event(keyboard_NUM[numstr[i] - '0'].kvalue,0,0,0); 		 		keybd_event(keyboard_NUM[numstr[i] - '0'].kvalue,0,KEYEVENTF_KEYUP,0); 	} 	keybd_event(18,0, KEYEVENTF_KEYUP,0);    } 请问两位我这样输入一个中文的时候怎么没反应那，例如“我”字我调试得到的是对应的52946，好像ALT组合键没起作用，请问是我的写法不对吗

user: user-4
content: http://baike.baidu.com/link?url=zt_1cauNfVDN3GUrqPfk-j7xgVU5-Gp2YMUzpB9A-8flJPCdp1uGZVdF7WqtlbZfFgxfIDQeGcQzZ63N1oLfK_   那些括号里面不也有!

user: user-3
content: 在MSDN里面搜“Key Scan Codes”