keybd_event在activex中不起作用,postmessage可以,但无法模拟VK_BACK
我正在开发一个可以与 JavaScript 交互的浏览器插件。我使用开源框架firebreath来开发插件,该插件将打包NPAPI(非ie浏览器)插件和activex(在ie中使用) )在一个 dll 文件中。
以下代码在使用 NPAPI 插件的非 ie 浏览器下完美运行("enter","delete","backspace ”键可以正确按下):
//VKey stands for the key users pressed like "VK_RETURN","VK_BACK","VK_DELETE",etc
keybd_event(Vkey,0, KEYEVENTF_EXTENDEDKEY | 0,0);
但是如果我在ie中运行插件,什么也没有发生。我也尝试了SendInput,但仍然什么也没有< /strong> 发生:
KEYBDINPUT kb={0};
INPUT Input={0};
kb.wScan = VK_BACK;
kb.dwFlags = KEYEVENTF_UNICODE;
Input.type = INPUT_KEYBOARD;
Input.ki = kb;
::SendInput(1,&Input,sizeof(Input));
奇怪的是按键组合正常工作即。例如(ctrl+x):
> keybd_event(VK_CONTROL, MapVirtualKey(VK_CONTROL,0), 0 ,0);
> keybd_event(bCharKey,(BYTE)0, 0 ,0);
> Sleep(10);
> keybd_event(bCharKey,(BYTE)0, KEYEVENTF_KEYUP,0);
> keybd_event(VK_CONTROL, MapVirtualKey(VK_CONTROL,0),
> KEYEVENTF_KEYUP,0);
所以我将 keybd_event 更改为 PostMessage:
::PostMessage(hbrowser,WM_KEYDOWN,vKey,1); //vKey stands for key pressed
::PostMessage(hbrowser,WM_KEYUP,vKey,1);
"VK_TAB","VK_DELETE","VK_RETURN","< strong>VK_TAB”、“VK_SPACE”有效,但“VK_BACK”无效。
I'm developing a browser plugin which would interact with javascript. I used the open-source framework firebreath to develop the plugin which would pack NPAPI(non-ie browsers) plugin and activex(used in ie) in one dll file.
The following code works perfectly under non-ie browsers which uses the NPAPI plugin("enter","delete","backspace" keys can be pressed correctly):
//VKey stands for the key users pressed like "VK_RETURN","VK_BACK","VK_DELETE",etc
keybd_event(Vkey,0, KEYEVENTF_EXTENDEDKEY | 0,0);
But if I run the plugin in ie,nothing happens.I tried SendInput too,but still nothing happens:
KEYBDINPUT kb={0};
INPUT Input={0};
kb.wScan = VK_BACK;
kb.dwFlags = KEYEVENTF_UNICODE;
Input.type = INPUT_KEYBOARD;
Input.ki = kb;
::SendInput(1,&Input,sizeof(Input));
Which is odd is the combination of keys works correctly in ie. eg(ctrl+x):
> keybd_event(VK_CONTROL, MapVirtualKey(VK_CONTROL,0), 0 ,0);
> keybd_event(bCharKey,(BYTE)0, 0 ,0);
> Sleep(10);
> keybd_event(bCharKey,(BYTE)0, KEYEVENTF_KEYUP,0);
> keybd_event(VK_CONTROL, MapVirtualKey(VK_CONTROL,0),
> KEYEVENTF_KEYUP,0);
So I change the keybd_event to PostMessage:
::PostMessage(hbrowser,WM_KEYDOWN,vKey,1); //vKey stands for key pressed
::PostMessage(hbrowser,WM_KEYUP,vKey,1);
"VK_TAB","VK_DELETE","VK_RETURN","VK_TAB","VK_SPACE" works,but "VK_BACK" doesn't work.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论