I have a C# application and an embedded browser in it; its task is to go to my web site and right click on a link and press 'r' so the properties window appears (I move the mouse with code). It works on my laptop perfectly, but when I install it on my pc or any other device, when the program does this command:
SendKeys.Send("r");
I start to see an error telling me:
Unhandled exception in your application. The requested resource is in use. (Exception from HRESULT:0x800700AA)
Here is my code which works on my laptop:
int x = getXoffset(link);
int y = getYoffset(link);
webBrowser1.Document.Window.ScrollTo(x, y);
Linker.Win32.POINT p2 = new Linker.Win32.POINT();
webBrowser1.Focus();
p2.x = webBrowser1.Left + 10;
p2.y = webBrowser1.Top + 10;
Linker.Win32.ClientToScreen(this.Handle, ref p2);
Linker.Win32.SetCursorPos(p2.x, p2.y);
MouseOperations.GetCursorPosition();
MouseOperations.MouseEvent(MouseOperations.MouseEventFlags.LeftDown);
MouseOperations.MouseEvent(MouseOperations.MouseEventFlags.RightDown);
MouseOperations.MouseEvent(MouseOperations.MouseEventFlags.RightUp);
SendKeys.Send("r");
What should I do? What does this error mean?
the mistake is because you webbrowser control is still navigate a workaround is to call invoke method of your webcontrol to a delegate that is associate to your sendkey
public delegate void Senddelegate();
Senddelegate = sendyourkey;
webBrowser1.BeginInvoke(new Senddelegate(sendyourkey));
public void sendyourkey()
{
SendKeys.Send("r");
}
you have to call asynchronously your sendkey to let browser finish process
User contributions licensed under CC BY-SA 3.0