开发者

Controlling cursor and keyboard with C++/Visual 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 开发者_Python百科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


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


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);


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜