I'm not sure what the keybd_event function does, but it evidentally expects a
BYTE
as its first argument. Generally a
BYTE
is typedeffed to an
unsigned char
or something similar.
However, you are passing the first element of an array of strings, specifically the string "A".
Please don't confuse HTML code and C++ code. You are writing C++ code that reads or writes HTML code. In this regard "A" is an ascii string which is interpretted by HTML as "A", but is interpretted in C++ as "A". The "A" that HTML sees is stored in C++ as a BYTE with the value 'A'.
You need a translation function to go from the HTML string to the BYTE that it represents, something like:
BYTE translateHtmlToByte(const std::string& htmlString);
This translation function could contain a very long if/else statement (as you suggested), or you could pre-populate some data structure (like a std::map<std::string, BYTE>) and your translation function would read values from that. Pre-population could be done by reading a configuration file if you wanted to so more and more HTML codes can be added in after you get the guts of your program working.
With the translation function, you code example would change to something like:
1 2 3
|
string HTML[1];
HTML[0] = "A"; //A
keybd_event(translateHtmlToByte(HTML[0]), 0, 0, 0);
|