I am trying to send mouse clicks to a WebBrowser control inside a form using PostMessage() and I am having a pretty significant problem. What I'm trying to achieve is to simulate mouse clicks on this web browser while my form is minimized. Normally PostMessage() will work just fine, but it seems to work only while my form has focus. This leads me to believe that there are some checks to check if a particular website that I load in my WebBrowser control is located before it processes mouse events.
This is how I send clicks with my program:
private void SendClick(Point location) { resetHandle = true; StringBuilder className = new StringBuilder(100); while (className.ToString() != "Internet Explorer_Server") { handle = GetWindow(handle, 5);
This is what resetHandle does:
private void timer3_Tick(object sender, EventArgs e) { if (resetHandle == true) { handle = webBrowser1.Handle; resetHandle = false; } }
I'm not sure if there is a better way to send mouse events to the background window, and I'm open to any ideas. What I'm really asking is, if at all possible, for the window to show that it is in focus when it is actually minimized?
Any help at all would be greatly appreciated!
source share