0

我不明白如何在 .NetWrapper 中使用此方法内容来注入键盘键(在 C# 中)我需要在调用该方法时模拟“Enter”键盘。(就像我真的按下回车键)

//   msg:
//     The Windows keyboard message (usually WM_KEYDOWN, WM_KEYUP and WM_CHAR).
//
//   wparam:
//     The first parameter of the message as intercepted by the window procedure.
//
//   lparam:
//     The second parameter of the message as intercepted by the window procedure.


protected void InjectKeyboardEventWin(int msg, int wparam, int lparam);

如果我不能使用这种方法来模拟“Enter”键,有没有办法用 javascript 来做到这一点?

关于javascript:

在 HTTP 表单中(我想模拟“输入”键)没有任何“提交”按钮。

因此,在 TextBot 中提交数据内容的唯一方法是使用“Enter”

PS我不能使用JQuery

4

1 回答 1

0

不确定 InjectKeyboardEventWin() 方法来自哪里,但 Windows 中的真正功能是:

VOID WINAPI keybd_event(
  __in  BYTE bVk,
  __in  BYTE bScan,
  __in  DWORD dwFlags,
  __in  ULONG_PTR dwExtraInfo
);

这将允许您模拟对当前具有焦点的任何应用程序的按键。您还可以使用类似的功能模拟鼠标事件。为了模拟按下 ENTER 键,您需要调用它两次;一次用于 keydown 事件,再次用于 keyup。您可以在此处查看详细信息:

关于 keybd_event 的 MSDN 文档

于 2011-12-23T00:04:07.710 回答