如何发送击键到窗口? [英] How to send keystrokes to a window?

查看:97
本文介绍了如何发送击键到窗口?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

im using keybd_event();我想使用SendMessage();发送击键到记事本,可以这样做吗? c>使用 SendMessage 在编辑缓冲区中插入文本(

im using keybd_event(); and i want use SendMessage(); to send keystroke to notepad, can this be done?

推荐答案

听起来像你想要的):

HWND notepad = FindWindow(_T("Notepad"), NULL);
HWND edit = FindWindowEx(notepad, NULL, _T("Edit"), NULL);
SendMessage(edit, WM_SETTEXT, NULL, (LPARAM)_T("hello"));

如果您需要键码和任意按键,可以使用 SendInput() (可提供2k / )或 keybd_event() `(最终会在较新的操作系统中调用SendInput):

if you need keycodes and arbitrary keystrokes, you can use SendInput() (available in 2k/xp and preferred), or keybd_event()` (which will end up calling SendInput in newer OSs) some examples here:

http://www.codeguru.com/forum/showthread.php?t=377393

还有您可能感兴趣的SendMessage的WM_SYSCOMMAND / WM_KEYDOWN / WM_KEYUP / WM_CHAR事件。

there's also WM_SYSCOMMAND/WM_KEYDOWN/WM_KEYUP/WM_CHAR events for SendMessage which you might be interested in.

这篇关于如何发送击键到窗口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆