Sending Clicks to Inactive Windows

I wasn't sure if this was better to post to the Windows Programming forum or here.

I've created a program that simulates clicking, but I can't figure out how to send it to a specific window without making the window active. I know there has to be a way (apparently autoit has some functions for it), but I can't find any way to do it in all my searching. I saw some sendInput function, but that doesn't seem to have any handling, and I've seen some postMessage function that has handling, but it doesn't (from what I've read) leave the window inactive. So far I haven't encountered anything that will keep the window inactive and send the mouse clicks/movement to it at the same time. Does anybody know any way to do it (or any workaround)?

Also, I sent my executable to a friend, and lo and behold, it didn't work at all. He was missing a .dll file. So I was wondering, how would one pack an executable so that it provides the files necessary if they aren't available, or do I need to figure out how to install those?
Last edited on
I'm not a WinAPI guy, but the code in this post http://www.rohitab.com/discuss/topic/27529-sending-keystrokes-to-inactive-window/?p=10019225 seems to do what you want.

As for the DLL issue, static linking should do the trick.
I'll try PostMessage, thanks.

How exactly does one static link their libraries? I remember that you can do that now, but I've never done it before.
What IDE and/or compiler do you use?
Sorry, I haven't been on my computer. I use Visual Studio 2013.
Project properties > Configuration properties > C/C++ > Code generation: set runtime libraries to mult-threaded (MT)for release and multi-threaded debug (MTd) for debug configuration.
If you use any external libraries you will need to rebuild them statically as well.
Last edited on
Thank you for your help! I'll get on that as soon as I get my homework done.
Topic archived. No new replies allowed.