|
-
July 23rd, 2006, 02:17 AM
#11
Re: Simulate Mouse Click
 Originally Posted by JBudOner
=/
[DllImport("user32.dll")]
public static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, UIntPtr wParam,
IntPtr lParam);
public const int WM_NCLBUTTONDOWN =0x00A1;
public const int WM_NCLBUTTONUP = 0x00A2;
private void button1_Click(object sender, EventArgs e)
{
Win32APICall.SendMessage(Web.Handle, Win32APICall.WM_NCLBUTTONDOWN, 544, 472);
Win32APICall.SendMessage(Web.Handle, Win32APICall.WM_NCLBUTTONUP, 544, 472);
}
So this is what I came out to now. Web being the name of the WebBrowser. Not sure if, 'WM_LBUTTONDOWN' is different from, 'WM_NCLBUTTONDOWN'. I checked around for a number that it would be, but couldn't find any. I've got an error when trying to run it, "Cannot convert from 'int' to 'System.UIntPtr'," and, "Cannot convert form 'int' to 'System.IntPtr'." I've got one of both of these for both the SendMessages. Any ideas?
'WM_LBUTTONDOWN' is different from 'WM_NCLBUTTONDOWN'! First means "window message left button down" and second means "window message non-client area left button down"! In my oppinion, it might be useless to send any of these messages to a window in order to hit a hyperlink within it. You could try detecting which message is processed when the hyperlink is hit by using something like Spy++, 'cause might not be WM_LBUTTONDOWN & WM_LBUTTONUP but also to idetify what parameters are expected when these messages are sent. I would recommend SendInput() for sending keyboard or mouse events. Also, I have used in the past mouse_event to simulate mouse events and I find it strange that doesn't work for you.
Regards,
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|