Jump to content
  • Advertisement
Sign in to follow this  
Crayolia

SendMessage(hwndALL, WM_HELP) -- 2nd weirdest error ever!

This topic is 5400 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm working on a C app that macro's a program, but doesn't require control over the user's mouse. I accomplish this by sending WindowMessages to the program that I have the HWND to.
POINT xy;
			//Click on the "Enter Game" button)*/
			xy.x = 125;
			xy.y = 290;
			SendMessage(hwndWindow, WM_MOUSEMOVE, 0,&xy);
			Sleep(100);
			SendMessage(hwndWindow, WM_LBUTTONDOWN, MK_LBUTTON,&xy);
			Sleep(100);
			SendMessage(hwndWindow, WM_LBUTTONUP, MK_LBUTTON,&xy);
			Sleep(100);



When I run Spy++, it says the message went through as like (x=-22000, y = 66), and it doesn't click on the button its supppose to. :( What am I doing wrong? [Edited by - Crayolia on October 6, 2004 8:44:42 PM]

Share this post


Link to post
Share on other sites
Advertisement
For input events, use SendInput instead of SendMessage. It essentially works the same, but you send information about the input and windows generates the messages itself.

The reason you're getting strange coordinate results is because the last paramater should not be a pointer to the POINT structure. The last parameter has the x and y values packed into the parameter itself. I'm not sure on the format, but if you look at the GET_X_LPARAM and GET_Y_LPARAM macros you could probably figure out how to do the opposite to turn an X and Y into an LPARAM (even though like I said you should use SendInput instead and for that you won't need to do this kind of thing).

Share this post


Link to post
Share on other sites
Quote:
Original post by Extrarius
For input events, use SendInput instead of SendMessage. It essentially works the same, but you send information about the input and windows generates the messages itself.


Edit: Wait a sec, how do I get it to send to another HWND?! Your overlooking the fact that the input gets sent to a different window.

Share this post


Link to post
Share on other sites
I'm not overlooking the fact, I'm just telling you the proper method of faking input events. SendInput sends the input exactly as if you had pressed the keys or done the movements yourself (for example, key presses go to the active window). If you want to use SendInput to fake key presses to a different window, you'd just activate the window before sending it input.

Share this post


Link to post
Share on other sites
Quote:
Original post by Extrarius
The last parameter has the x and y values packed into the parameter itself. I'm not sure on the format, but if you look at the GET_X_LPARAM and GET_Y_LPARAM macros you could probably figure out how to do the opposite to turn an X and Y into an LPARAM (even though like I said you should use SendInput instead and for that you won't need to do this kind of thing).


I believe the macro is MAKELPARAM(x, y), but I'm not 100% sure.

Share this post


Link to post
Share on other sites
Quote:
Original post by Extrarius
I'm not overlooking the fact, I'm just telling you the proper method of faking input events. SendInput sends the input exactly as if you had pressed the keys or done the movements yourself (for example, key presses go to the active window). If you want to use SendInput to fake key presses to a different window, you'd just activate the window before sending it input.


Yes.. you ARE overlooking the fact. You just won't admit it. Read my post over a few times and realize that activating a window is going to take control away from the user.

Pffttt.. proper.... what a joke.

I did some scavanging and found the answer posted on another website, thank you Aprosenf for that function, if I hadn't found one that worked, I prolly would have used that one.

This is what I'm using to pack the two shorts into a long.

int fMakeLong(int LoWord, int HiWord)
{
return (HiWord << 16) | (LoWord & 0xffff);
}




[Edited by - Crayolia on October 7, 2004 12:46:04 AM]

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!