简体   繁体   English

我需要使用javascript在浏览器中将关键事件触发到SWF

[英]I need to fire key events to a SWF, in a browser, using javascript

So, I've got an idea flowing and I need to fire keyboard events to an embedded swf on a webpage (in Chrome). 因此,我有了一个主意,我需要将键盘事件发送到网页上的嵌入式SWF(在Chrome中)。

And I'm dealing with some limitations: 我正在处理一些限制:

  • The input events have to come from javascript 输入事件必须来自javascript
  • The events need to be fired to a swf 需要将事件发送到瑞士法郎
  • I do not have access to the source of the swf 我无法访问瑞士法郎的来源

How I get this done, doesn't really matter. 我如何完成此任务并不重要。 It's more of a personal project, so it can have as many loopholes as I wish. 它更多是一个个人项目,因此可以有我所希望的漏洞。

I've investigated firing directly from javascript, but I concluded that this is simply not possible. 我已经直接从javascript中进行了调查,但是得出结论,这根本不可能。 Does anyone else have any ideas? 还有其他人有什么想法吗? Could I for example use the Win32 API somehow? 例如,我可以某种方式使用Win32 API吗?

I'm assuming the SWF is your own, in which case you can use the ExternalInterface.call(); 我假设SWF是您自己的,在这种情况下,您可以使用ExternalInterface.call();。 method to execute JS directly in the host page, and you can use the ExternalInterface.addCallback() function to register AS functions as callable on the SWF with JS. 直接在宿主页面上执行JS的方法,您可以使用ExternalInterface.addCallback()函数将AS函数注册为可在带有JS的SWF上调用的AS函数。

docs docs

If you don't have access to swf's source, it's impossible, as the only way to do this is to register callbacks in flash and call them in JS. 如果您无权访问swf的源,那是不可能的,因为这样做的唯一方法是在flash中注册回调并在JS中调用它们。 Every callback, of course, must use dispatchEvent method to trigger the event you want (or call event-listening function directly). 当然,每个回调都必须使用dispatchEvent方法来触发所需的事件(或直接调用事件侦听函数)。

The only way to solve you problem is to decompile .swf (using Sothink SWF Decompiler, for example). 解决问题的唯一方法是反编译.swf(例如,使用Sothink SWF反编译器)。 If it's code is not obfuscated, the output code will be enought clear to read and refactor it. 如果没有混淆代码,则输出代码将足够清晰以读取和重构它。 Decompile, add callbacks (use ExternalInterface.addCallback()) and compile it a new time. 反编译,添加回调(使用ExternalInterface.addCallback()),然后重新编译它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM