有没有办法用C++模拟Windows输入?
我想知道是否有可能用C++制作一个可以“按下”按键的程序,或者让计算机认为已经按下了某些键,并做一些事情,比如制作一个“玩”游戏的程序,或者自动输入一些长而复杂的内容。没人能记住的模糊按钮序列。
(我现在想不出任何密码,但保存游戏密码可能是一个例子,特别是当你不能只输入它,而是必须将光标移动到你想要的字母,然后按 Enter 键或其他键时)。
就是想。
I'm wondering if its possible to make a program in C++ that can "press" keys, or make the computer think certain keys have been pressed, and do things like make a program that "plays" games, or automatically enter some long and obscure button sequence that no one could remember.
(I can't think of any right now, but savegame passwords might be an example, especially when you can't just type it, but have to move a cursor to the letter you want, then press enter or something).
Just wondering.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
http://msdn.microsoft.com/en-us /library/8c6yea83(VS.85).aspx
http://msdn.microsoft.com/en-us/library/8c6yea83(VS.85).aspx
RaymondC 认为这通常是一个坏主意:
http:// /blogs.msdn.com/oldnewthing/archive/2005/05/30/423202.aspx
如果您真的想要制作一个令人信服的键盘,则必须编写一个假装的设备驱动程序成为键盘。 但在紧要关头,或者如果您正在编写测试代码,SendInput 会完成它。
RaymondC suggests that this is a bad idea in general:
http://blogs.msdn.com/oldnewthing/archive/2005/05/30/423202.aspx
If you really want to make a convincing keyboard, you have to write a device driver that pretends to be a keyboard. In a pinch though, or if you're writing testing code, SendInput will do it.