是否可以使用JavaScript创建计算机宏(键盘事件等)

Is it possible to create computer macros (keyboard events and such) using JavaScript?

本文关键字:键盘 事件 计算机 可以使 JavaScript 创建 是否      更新时间:2023-09-26

由于与编程宏混淆(比如Lisp的亮点),我找不到有用的结果。你能使用JavaScript配置计算机宏吗?比如"将键输入发送到窗口"?

子窗口可以从其父窗口或打开窗口调用函数。因此,您可以通过在父窗口(如)上创建函数来模拟这种行为

function acceptKey(val) {
   alert(val);
}

然后在子窗口上,您可以调用函数

window.parent.acceptKey("Test"); // If iframe
//or if new window
window.opener.acceptKey("Test2");

在相互不相关的窗口上,则没有。