[英]How to fire keystrokes out of the browser onClick event?
Let's say we have a simple button: 假设我们有一个简单的按钮:
<button type="button" onclick="onClickHandler()">Click Me!</button>
How can you do the following on: onClickHandler() 您如何在以下方面执行以下操作: onClickHandler()
Is it possible? 可能吗? How? 怎么样?
Edit, To add more details/context to my question: 编辑,为我的问题添加更多详细信息/上下文:
What I am trying to achieve here is to make a convenient button on a web page that will auto generate a message based on a template, eg 我在这里想要实现的是在网页上创建一个方便的按钮,该按钮将基于模板自动生成消息,例如
"Hi ${name}, I would like to buy ${item} from your for this ${price}". “您好$ {name},我想从您那里以$ {price}的价格购买$ {item}”。
This message would then be sent in another active running window, and then the message is typed in (like a macro) and then sent!. 然后,该消息将在另一个活动的运行窗口中发送,然后键入该消息(如宏),然后发送! After sending, the window focus should still be the Browser. 发送后,窗口焦点仍应为浏览器。
Found my solution 找到了我的解决方案
Instead of javascript doing the hardwork. 而不是用JavaScript来完成工作。 js will just put the generated string into the clipboard, and fire a keystroke. js只会将生成的字符串放入剪贴板,然后击键。 This keystroke will be detected by AHK ( http://ahkscript.org/ ). AHK( http://ahkscript.org/ )将检测到此击键。 And then AHK can do the rest. 然后AHK可以完成其余的工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.