○如何用API的SendMessage发*送*回*车?

foolfool 2005-12-02 03:05:25
要向其他窗口发送回车键该如何写?

是用下面的方法吗?

SendMessage(EdithWnd, WM_KEYDOWN, ????,????);
后面两个参数该怎么设??
用spy++捕捉 发现按下回车之后有三条消息:

WM_KEYDOWN nVirtKey:VK_RETURN
WM_CHAR chCharCode : '000D'(13)
WM_KEYUP nVirtKey:VK_RETURN

谢谢!
...全文
210 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
foolfool 2005-12-05
  • 打赏
  • 举报
回复
楼上的兄弟,是不同进程间的.
whmjw 2005-12-02
  • 打赏
  • 举报
回复
System.Windows.Forms.SendKeys.Send("{Enter}");
就行了
兔子-顾问 2005-12-02
  • 打赏
  • 举报
回复
SendMessage(EdithWnd, WM_KEYDOWN, (Long)13,(Long)0);












WM_KEYDOWN
The WM_KEYDOWN message is posted to the window with the keyboard focus when a nonsystem key is pressed. A nonsystem key is a key that is pressed when the alt key is not pressed.

WM_KEYDOWN
nVirtKey = (int) wParam; // virtual-key code
lKeyData = lParam; // key data

Parameters
nVirtKey
Value of wParam. Specifies the virtual-key code of the nonsystem key.
lKeyData
Value of lParam. Specifies the repeat count, scan code, extended-key flag, context code, previous key-state flag, and transition-state flag, as shown in the following table. Value Description
0–15 Specifies the repeat count for the current message. The value is the number of times the keystroke is auto-repeated as a result of the user holding down the key. If the keystroke is held long enough, multiple messages are sent. However, the repeat count is not cumulative.
16–23 Specifies the scan code. The value depends on the original equipment manufacturer (OEM).
24 Specifies whether the key is an extended key, such as the right-hand alt and ctrl keys that appear on an enhanced 101- or 102-key keyboard. The value is 1 if it is an extended key; otherwise, it is 0.
25–28 Reserved; do not use.
29 Specifies the context code. The value is always 0 for a WM_KEYDOWN message.
30 Specifies the previous key state. The value is 1 if the key is down before the message is sent, or it is 0 if the key is up.
31 Specifies the transition state. The value is always 0 for a WM_KEYDOWN message.

111,120

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • AIGC Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧