将击键发送到嵌入网络浏览器控件中的 Flash/Silverlight 应用程序(大部分已完成)
注意:这似乎不一定只适用于 Silverlight,我读到人们对 Flash 也有同样的问题,所以请记住这一点。
我正在尝试编写一个程序来控制通过我自己的按钮(目前,最终它将扩展到移动远程控制应用程序),使用 Windows API 直接向其发送热键。
- 我能够检索 Netflix Silverlight 播放器使用的实际窗口句柄。
- 我能够将击键发送到指定的窗口句柄(使用 win api 中的 TranslateMessage 函数),
- 但由于某种原因,我无法让 netflix 播放器识别我发送的任何击键。
- 在尝试发送按键之前,我尝试过在 win api 中使用
SetFocus
函数,但这没有帮助。
我需要弄清楚的是,为什么它要区分通过 api 调用发送的按键和物理键盘按键。
这是我的设置方式(窗口类名称供参考):
Form1(
<块引用>WindowsForms10.Window.8.app.0.33c0d9d
)Web 浏览器控件(
<块引用>Shell DocObject 视图
)HTML 页面 (
<块引用>Internet Explorer_Server
)嵌入式 Silverlight 播放器 (
MicrosoftSilverlight
)
我想知道是否有人能够提供一些建议。预先非常感谢..希望有人能帮助我度过这个难关。
NOTE: This doesn't seem to necessarily apply to Silverlight only, I've read people have the same problems with Flash, so keep that in mind.
I'm trying to write a program that will control Netflix through my own buttons (for now, eventually it will be extended to a mobile remote control app), by sending hotkeys directly to it using the windows api.
- I am able to retrieve the actual window handle used by the Netflix Silverlight player.
- I am able to send keystrokes to specified window handles (using the
TranslateMessage
function in win api) - But I cannot, for some reason, get the netflix player to recognize any keystroke I send.
- I have tried using the
SetFocus
function in the win api before attempting to send keypresses and that doesn't help.
What I need to figure out, is why it's differentiating keys sent via api calls, from physical keyboard key presses.
Here's how I have things set up (window class names for reference):
Form1 (
WindowsForms10.Window.8.app.0.33c0d9d
)WebBrowser Control (
Shell DocObject View
)HTML Page (
Internet Explorer_Server
)Embedded Silverlight player (
MicrosoftSilverlight
)
I was wondering if someone might be able to offer some suggestions. Thanks very much in advance.. hopefully someone can help get me through this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我尝试将 KeyEvents 发送到 C# 中的 Flash 应用程序(我想“破解”名为“CLOP”的悲伤游戏)。
我注意到这不起作用。然而,我可以完美地将 KeyEvents 发送到浏览器本身,但即使在获得焦点后,flash 插件似乎也会忽略这些事件。
我怀疑由于安全措施的原因这是不可能的。
我在 StackOverflow 上找到了以下线程,它对此进行了更多解释(这也是关于闪存的)
将键盘和鼠标事件发送到 Flash 影片
I tried to send
KeyEvents
to a flash application in C# (I wanted to 'hack' the griefing game called "CLOP").I noticed this didn't work. I can however perfectly send
KeyEvents
to the browser itself but the flash plugin seems to ignore these even after acquiring focus.I suspect this isn't possible because of security measures.
I found the following thread here on StackOverflow that explained a bit more about this (this one is about flash as well)
Send keyboard and mouse events to Flash Movie