The keybd_event function acts just as if you had pressed the corresponding keys on the keyboard. Thus, if the window you want to send to is not in focus, the keystrokes will not reach it.