Zakum
Zakum

Reputation: 491

How do I create a program that presses a key in C++?

I am trying to create a macro program in C++. The program is supposed to press the H key once in every 10 seconds. I have got the timing functions already, but how do I make it hit a key? So while the program runs, if I go to Notepad and leave it there, it would type "hhhhhhhh(...)"

Thanks!

Upvotes: 2

Views: 4751

Answers (1)

Stardidi
Stardidi

Reputation: 306

A quick search turns up this question has been answered before: How to simulate a key press in C++

Their accepted answer was to use SendInput()

It completely depends on your idea in mind, but i personnaly find that if i want to make some kind of macro program AutoIt is THE way to go.

Upvotes: 6

Related Questions