Try to use SendInput API rather than sending WM_CHAR message.