I'm working on a little automation module for key presses and mouse-clicks, and while I've found the documentation for SendInput() and the Virtual Key Codes quite helpful for the standard keyboard and mouse input, I'm not sure how I can accomplish this task with the less ASCII-friendly potential input, like say, ®, or ê, which would be really helpful when trying to send localized strings to text fields.
I was thinking that using simulated key-presses was the way to go, but now I'm wondering if I should resort to some other sneaky devilry, like putting the string into the clipboard and doing a CTRL + V operation, or something like that and only sending virtual key-presses when appropriate.
My thought was doing something like this for all the specifically keyboard keys:
std::map<std::string,int> keys {
{"0", 0x30},
//...
{"F24", 0x87}
};
Then iterating through each command line argument character-by-character to see if the whole arg only uses keys in the keys map in reference to the virtual key codes. If it does, just simulate the sequence of virtual keyboard key-codes with SendInput(). If it doesn't, I'm assuming it's not a valid direct key-press, and would do something like,
std::string to_send = argv[1];
pasteClipboard(to_send);
Is there a more straight-forward way to accomplish my goal? If not, any suggestions on how to implement a pasteClipboard style of method? I'm not using anything like Forms or MFC and would prefer to stick to the WINAPIs.
WDA_MONITORdisplay affinity of a window.