Skip to main content
GameDev.net gamedev.net
🔒 Locked

Window Messages

Started by Westeria Dec 24, 2004 at 8:41 PM 2 replies 950+ views
Original Post
Westeria
Westeria
I'm trying to write a program that drag files, draw pictures, and rename stuff without the need to use the cursor. I'm going this through Window Messages. Currently I'm experiamenting on an autoplaying proggy for an advanced minesweeper game. Here is what my code looks like..
void sClickAndDrag(unsigned short intX,unsigned short intY,unsigned short intDestX,unsigned short intDestY)
{
	SendMessage(hwndWindow, WM_LBUTTONDOWN, 0,fMakeLong(intX,intY));	
	PostMessage(hwndWindow, WM_MOUSEMOVE, MK_LBUTTON,fMakeLong(intDestX-5,intDestY-5));
	SendMessage(hwndWindow, WM_LBUTTONUP, 0,fMakeLong(intDestX,intDestY));	
}
This code doesn't work however. I've used Spy++ to make sure the HWND value and everything was working, and it was. Is there a problem with my code, or is it just that some programs handle messages different than others? (I've tried shifting the Post & send thingies around, no success. )
chollida1
chollida1
you can also try using SendInput. But as far as the code you've written remember that SendMessage Blocks until the message is sent and responded to while PostMessage is non blocking and returns after putting the message in teh message que.

The code you posted more often than not will result in your window recieving the following messages in the following order

WM_LBUTTONDOWN
WM_LBUTTONUP
WM_MOUSEMOVE

Cheers
Chris
CheersChris
Westeria
Westeria
Hrm.. very strange bug.

The code works ONLY IF, I move the mouse a few pixels while it running. If I don't move the mouse, the code doesn't work.

eg.. the mouse doesn't need to be moved on the window its sending them too, it just has to get moved. Which is strange because, just moving the mouse over the desktop isn't gonna generate any Window Messages to the window.

Strange? Or did I miss something.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.