I'm trying to develop a keyboard emulator, controlled by the mouse, but with only partial success. The first mouse click on my keyboard emulator window kills the focus of the keyboard receiving window. After returning the focus (SetForegroundWindow()) some programs lose possition of the cursor, so further keyboard input is impossible. Though I saw a keyboard emulator program, which allows to press virtual key buttons, without taking over the keyboard focus. How this is ever possible? Any ideas how to do that - preserve keyboard focus of one window when clicking mouse on another? I'm using standard Windows API environment.