What version of windows are you using?
If you are using Vista+, is the target application running with elevated permissions?
If yes, is your application also running with elevated permissions?
If no, see : UIPI
Newer versions of Windows actively disallow an application with a lower privilege sending messages to an application with higher privilege. There are a few ways around this, either by making your application run with elevated permissions or by including an application manifest that sets uiAccess
to true. In the latter case, the application must be authenticode signed and must be executed from a trusted location (ie: Program Files
directory, etc.).
Otherwise, there is no way to simulate mouse activity at the low level without introducing a new hardware driver. Hardware drivers run in Ring-0 and to completely simulate real mouse activity (not just 'fake' messages) you would need to do it at this level.