使用 C++/Visual C++ 控制光标和键盘

发布于 2024-08-18 13:01:54 字数 339 浏览 3 评论 0原文

这次我有一个关于C++的问题。我使用 Dev-C++ 进行编程,但我还安装了 Visual C++ Express,所以两者都很好。我正在创建一个类似自动化任务的程序,是..宏吗?但由于我是 C++ 新手,因为我一周前开始使用它,所以我需要帮助。请保持简单的答案:-D 这是我 C++ 学习进度的一部分。

另外,我尝试用谷歌搜索这些内容很长时间但没有成功,所以我不想听到与搜索相关的答案。

如何在屏幕上移动光标?这应该是可能的,因为一切都是如此,但是有没有任何简单的方法/功能可以做到这一点。我还需要单击鼠标按钮。

这一定是一件简单的事情:按键。我对此没有什么可补充的。

希望你能帮忙., 马蒂·莱恩

This time I have a question about C++. I'm using Dev-C++ for programming, but I also have Visual C++ Express installed so both are good. I'm creating a program like automated tasks, is it.. macro? But as I'm a noob in C++, because I started it a week ago, I need help. Please keep the answers simple :-D This is a part of my learning-progress in C++.

Also, I tried to Google these for a long time without success, so I'd not like to hear answers relating to searching.

How is it possible to move cursor around the screen? This should be possible, as everything is, but is there any simple way/function to do this. I also need to click mouse-buttons.

This one must be a simple one: Pressing keys. I have nothing to add into this.

Hope you can help.,
Martti Laine

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

风吹雨成花 2024-08-25 13:01:54

如果您要写入控制台,您宁愿使用类似 conio.hcurses

If you're writing to the console, you'd rather use something like conio.h or curses.

梦幻之岛 2024-08-25 13:01:54

您可以使用 Windows API 中的 keybd_event 函数。例如:

HWND hwnd = FindWindowA(NULL,"Untitled - Notepad");
AppActivate(hwnd);
keybd_event(VkKeyScan('A'), 0, 0, 0);

You can use keybd_event function from Windows API. For example:

HWND hwnd = FindWindowA(NULL,"Untitled - Notepad");
AppActivate(hwnd);
keybd_event(VkKeyScan('A'), 0, 0, 0);
花心好男孩 2024-08-25 13:01:54

既然您觉得自己此时处于菜鸟级别,我相信对您来说最简单的路径是构建一个 控制台应用程序,使用 诅咒库。这不是一个完美的解决方案,但是学习曲线不那么陡峭,一旦你掌握了它,学习更多类似 gui 的方法的曲线应该不那么陡峭。

Since you feel that you are at noob level at this point, I believe that the simplest path for you is to build a Console Application, using a curses library. It is not a perfect solution, but the learning curve is less steep, and once you master it the learning curve to more gui like methods should be less steep.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文