0

试图找到一种方法来模拟键盘输入,如此处所示(c#)但在 javascript 中:

[DllImport("user32.dll", EntryPoint = "FindWindow", SetLastError = true)]
static extern IntPtr FindWindowByCaption(IntPtr ZeroOnly, string lpWindowName);

[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
static extern bool SetForegroundWindow(IntPtr hWnd);

// inputsim instance
public static InputSimulator inp_sim = new InputSimulator();

SetForegroundWindow(FindWindowByCaption(IntPtr.Zero, "Untitled - Notepad"));

inp_sim.Keyboard.KeyPress(VirtualKeyCode.VK_A);

还没有找到一种方法在javascript中将按键事件设置到其他窗口,所以如果有人能指出我正确的方向,将不胜感激:)

4

0 回答 0