Maybe you can help me here triumph, or anyone else for that matter.
I have users running my program on various operating systems, and am running into two common problems. The window\game window my program sends messages to and gets pixels from is an older direct x game coded in c++. When the user goes to full screen for some the program stops working. Now what has me pulling my hair out is on a win7 pro edition box using XP mode emulation my program runs fine. However... on windows7 home premium my user reports the program doesnt work..

I have a few things to isolate the issue to SendMessage(), and ahve tried using PostMessage() as well with the same outcome.

The program is getting the windows handle and not reporting an error. The registerhotkey is returning an error although this might be due to another program using the same hot key I havent looked into it yet. When I set my program to setpixel() to the game scren for troubleshooting it is painting on the games screen. So when my program using getpixel() locates a color of interest and sends a double click the failure is in the mouse not being double clicked to the location.

It is 32bit win7 OS.

I have googled quite a bit and cannot find information on why send message is not working on this OS, or if it should work at all. I dont know if sendmessage() should even work at all on win7 home premium etc.. Absolutely stumped.

Any information or workaround would be greatly appreciated.

5 Years
Discussion Span
Last Post by ashishchoure

try and see if you can get the handle right before sending the message and output and error if the handle returns NULL... As far as I know, the window name disappears when you run it in fullscreen mode and that may be the cause of send message failure. I had that problem and instead had to Check constantly if the process was running in a separate thread. You can always do an EnumWindows to find it instead.

SendMessage does work on HomePremium as I have used it before on that OS.. but I believe strongly that its losing the handle when it maximizes (possible handle change?) or it cant find the window name since the title bar disappears.. Try alt+Tab and open spy++ and check.


thats just it. For windows 7 home premium. It is not working what so ever, and all while in windowed mode it does not work, but for all others it is. I havent tested it on a second win7 home premium box to see if maybe its just that users machine.

As for win7 pro, and windows vista when the game screen goes full screen it stops working, and I do run a constant check within my program for the HWND to see if it fails or not and it doesnt fail when the switch to full screen is made.

However on XP theres no problems whether I switch from full screen and back.. it stays working...

Just got report from my win7 pro user that it does work but it runs slow.
Any suggestions ?

Good to know that it should work for the win7 user, but its not at all working.
Yet it works for VIsta 32bit, XP PRO, Win7 pro with xp mode emulation, but so far NOT the home win7.

If I set my program to paint using setpixel() it paints to the games screen for the win7 home user, and the color finding logic works, but its sending clicks to that game screen thats not working. SO this lets me know the hwnd to the game is good, and the only thing failing is PostMessage(), and SendMessage();.

Any thoughts?


Hmm I dont know any GOOD alternatives to spy++ off the top of my head.. I'd have to search that up.. as for everything working except post message, This can possible be because of the theme. Windows 7 has many different themes + aero + the taskbar properties.
I do know microsoft had some hotfix/patch so that homepremium would have xp emulation but I cant find it :S

Post Message and SendMessage works as long as the program is accepting it. If its being posted to the window itself rather than the message queue then it wont register clicks. The Window itself probably only registers minimize, maximize and close.

Basically to see if post message/send message is working, try sending a message or posting a message like WM_CLOSE or ShowWindow(handle, SW_HIDE) that way you know for sure the handle hasnt change and you know for sure the window is receiving messages. But there is no way that I personally know of to check if the window's message queue is accepting messages. (well without hooking of course)

That being said, send a WM_CLOSE or some message like minimize or something and see what happens.. if it works then the window itself is getting messages. Also are you posting the clicks to a specific location in the window? maybe a specific co-ordinate? or are you fully relying on it to find the pixel then click it? Because pixel's on every computer will be different unless it has a tolerance to the colour. Also after trying everything above, try just sending a click to any part of the game window without the pixel finding and post back the results of all the attempts above. That way I/The Forum can figure out whats wrong.

Edited by triumphost: n/a


As per my knowledge due to some security issue on vista and above os's SendMessage and PostMessage Api are disabled if they used to send message across process. You can use this API to send msg within process, parent wnd to child wnd. We had faced same problem. To overcome this we used pipes and memory mapped files.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.