Generating Windows Events

Started by
17 comments, last by imadoki 18 years, 1 month ago
Ok, the stuff works great, I just get the HWND, then get its position, then add the no. of pixles to the button and viola!

Now, I need to bug you guys some more. I want this stop gap solution to be a little more elegent, so the HWND of the child window that contains the buttons will be of the dims 10x10 so that nothing in it can be seen. Now, how do I simulate a mouse click inside this window?

Ok, I will state it in another way, just incase the 1st was too loopy...

So, I have a dialog box, that has a child "container" which contains the buttons. For the sake of making it look clean, I will make this "container" window (hwnd) of the dim 1x1 or 10x10 and then would like to simulate a mouse button click on a button contained in this HWND. So, as you can guess, I have the HWND pointer at my disposal. Please help.

You guys gave me an amazing work around the instant I asked. I would be extremely grateful if you could present ideas and solutions for this aswell.

Thanks.
Advertisement
You cannot correctly simulate a mouse event to something that could not be interacted with normally.

You can partially simulate the mouse event using SendMessage, which is probably good enough for your situation
"Walk not the trodden path, for it has borne it's burden." -John, Flying Monk
I can use SendMessage to post WM_LBUTTONDOWN, but it isn't working, I guess the mouse pos. Is it lParam or wParam and how do you send the pos using SendMessage?

I used google, but I still can't find the answer to this, please pleeeeeease help.

EDIT: FYI, I cannot get the hwnd handles for the individual buttons, hence...
Quote:Original post by imadoki
I can use SendMessage to post WM_LBUTTONDOWN, but it isn't working, I guess the mouse pos. Is it lParam or wParam and how do you send the pos using SendMessage?

Quote:From WM_LBUTTONDOWN
wParam
Indicates whether various virtual keys are down. This parameter can be one or more of the following values.
MK_CONTROL
The CTRL key is down.
MK_LBUTTON
The left mouse button is down.
MK_MBUTTON
The middle mouse button is down.
MK_RBUTTON
The right mouse button is down.
MK_SHIFT
The SHIFT key is down.
MK_XBUTTON1
Windows 2000/XP: The first X button is down.
MK_XBUTTON2
Windows 2000/XP: The second X button is down.

lParam
The low-order word specifies the x-coordinate of the cursor. The coordinate is relative to the upper-left corner of the client area.

The high-order word specifies the y-coordinate of the cursor. The coordinate is relative to the upper-left corner of the client area.

In other words:
SendMessage(hwnd, WM_LBUTTONDOWN, MK_LBUTTON, MAKELONG(x_coord, y_coord));
Hi,

I tried that a few minutes after I posted my last post. I found the info on google, but guess what? it doesn't work. :(

Would you have any other solution to this?

Thanks.
Works for me. Sure you're sending it to the right Window?

Edit: Typo.

"Those who would give up essential liberty to purchase a little temporary safety deserve neither liberty nor safety." --Benjamin Franklin

Quote:Original post by Mike2343
Works for me. Sure you're sending it to the right Window?[...]
I know for certain he is not:
Quote:Original post by imadoki
[...]EDIT: FYI, I cannot get the hwnd handles for the individual buttons, hence...
Is there any reason you can't get the window handles for the individual buttons?
"Walk not the trodden path, for it has borne it's burden." -John, Flying Monk
Sounds to me like he's trying to "hack" a program. It'd be a shame for you to do all of this work just to find out that the developer had already thought that someone would be stupid enough to try exactly that :)

You know, those trial-period programs where some of the feature buttons have been disabled? I think he's trying to programmatically click those :P

..That or he's trying to write a macro for an online game -.-
Really guys, I am not trying to hack, except my company's old code!

The thing is, the old system was a spaghetti system with an old Win32 program with some sort of own scripting program (in house made) that displays buttons etc.

The thing is we are going more for the elegent solution as we will be using Java. But till we can roll it out, we were doing this. Anyway, we are probably going to be concurrently running 2 sever versions instead of 1 for now.

Thanks anyway.

Ya, and it still isn't working. :-(

This topic is closed to new replies.

Advertisement