1

I did hook the keyboard of some process. Now I need to change the key message sent to the process.

For example: from lowercase to uppercase and opposite.

How can I do this?

Mat
  • 202,337
  • 40
  • 393
  • 406
Leon
  • 21
  • 3

1 Answers1

0

Assuming your function prototype is as follows: LRESULT CALLBACK WndProc( HWND hWnd, UING uMsg, WPARAM wParam, LPARAM lParam ), the value of your letter is inside wParam. Assuming pure ASCII keyboard input, then you can use the following:

short newKeyCode = (char)wParam;
if (uMsg == WM_CHAR || uMsg == WM_SYSCHAR)
if (newKeyCode - 'a' < 26) {
  newKeyCode = newKeyCode - 'a' + 'A';
} else {
  newKeyCode = newKeyCode - 'A' + 'a';
}

Of course, if you're on a Windows system beyond 2000 (and thus running on the NT architecture), wParam will be a Unicode value (and UTF-16, as is the Windows convention), so your program may have to fiddle with this to get it into a nice state, but otherwise this should be all you need.

Ben Stott
  • 2,218
  • 17
  • 23