Hi,
I'm very, *very* new to C programming, please help :3
I want to make a program that types a message for me, like this:
include <stdio.h>
include <windows.h>
include <iostream>
include <conio.h>
using namespace std;
int main()
{
Sleep(3000);
int message_length = 10;
int message[] = {0x44, 0x43, 0x44, 0x43, 0x44, 0x43, 0x44, 0x45, 0x44, 0x45};
INPUT in[message_length*2] = {};
ZeroMemory(in, sizeof(in));
//Keyboard input
int store_input = 0;
for(int i = 0; i < message_length; i++)
{
in[store_input].type = INPUT_KEYBOARD;
in[store_input].ki.wVk = message[i];
in[store_input].ki.dwFlags = KEYEVENTF_EXTENDEDKEY;
store_input ++;
in[store_input].type = INPUT_KEYBOARD;
in[store_input].ki.wVk = message[i];
in[store_input].ki.dwFlags = KEYEVENTF_KEYUP;
store_input ++;
}
SendInput(message_length*2, in, sizeof(INPUT));
return 0;
}
This does work. The program in this case writes "dcdcdcdede", because e.g. 0x44 translates to the "d"-key:
https://learn.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes
However, I would like to write a string into the array message[] and then convert it into the hexadecimal values of the corresponding virtual key codes, so that I can quickly change the message array.
E.g.: message[] = "Hello World";
Is there any way of doing this?