Typing

What is the proper line of code to make my program type in an address bar or just type in general?

Like I use this to make my mouse click:

mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);

So I have a note pad that comes up and I want my program to type in "hello".

I feel it should be something simple like keyboard_event or something.

Let me know if anyone has any ideas please.

EDIT: or a better example would be, I want my program to press the letter H then release it, so what ever program is running the letter H is pressed once.
Last edited on
I found something that does what I want but It seems overly complicated just to make the letter "A" appear on screen... Is there an easier way?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#define WINVER 0x0500
#include <windows.h>

int main()
{
    INPUT ip;
    ip.type = INPUT_KEYBOARD;
    ip.ki.wScan = 0;
    ip.ki.time = 0;
    ip.ki.dwExtraInfo = 0;

    ip.ki.wVk = 0x41; // virtual-key code for the "a" key
    ip.ki.dwFlags = 0;
    SendInput(1, &ip, sizeof(INPUT));

    ip.ki.dwFlags = KEYEVENTF_KEYUP;
    SendInput(1, &ip, sizeof(INPUT));

    Sleep(10000);
}

Topic archived. No new replies allowed.