Skip to content
Prev 60780 / 63421 Next

Rgui.exe 4.2.0 does not receive characters via the Windows API's PostMessage function

On 5/16/22 19:21, Tomas Kalibera wrote:
Dear Jose,

to send non-ASCII and repeated characters, you can modify the loop above 
as follows (use wchar_t to send Unicode characters, send also 
KEYEVENTF_KEYUP events to ensure that repeated characters such as ')' in 
the example are received). Otherwise, please refer to the MSDN 
documentation.

 ? wchar_t *sd = L"(s <- c('?', 'b', 'c', '?'))";
 ? for(i = 0; i < wcslen(sd); i++) {
 ??? INPUT input;

 ??? ZeroMemory(&input, sizeof(INPUT));
 ??? input.type = INPUT_KEYBOARD;
 ??? input.ki.dwFlags = KEYEVENTF_UNICODE;
 ??? input.ki.wScan = (unsigned) sd[i];
 ??? res1 = SendInput(1, &input, sizeof(INPUT));

 ??? ZeroMemory(&input, sizeof(INPUT));
 ??? input.type = INPUT_KEYBOARD;
 ??? input.ki.dwFlags = KEYEVENTF_UNICODE | KEYEVENTF_KEYUP;
 ??? input.ki.wScan = (unsigned) sd[i];
 ??? res2 = SendInput(1, &input, sizeof(INPUT));

 ??? printf("Sending char %lc (%x): %d,%d .\n", sd[i], sd[i], res1, res2);
 ? }

Best
Tomas

Thread (13 messages)