The problem occurs when I choose a different tab in my custom application.
It is similar to a standard browser where you can open new tabs.
I can then run a script in one tab, open another, and run a different one.
Each tab with its own browser window.
So I try this on a blog service where I've created a blog.
When I run the script while I'm watching (tab active) it just works fine. Title is saved fine when exit the page and open it up again.
BUT!
When I run the script and quickly select another tab it just doesn't work. It is specifically for the title for some reason. If I insert text below the title the text is saved but not the title.
I figure it has to do with cefsharp mouseclick event. It behaves differently when the tab is not active.
I use these two functions for mouse click
- Code: Select all
public void MouseLeftDown(ChromiumWebBrowser _browser, int x, int y)
{
_browser.GetBrowser().GetHost()
.SendMouseClickEvent(x, y, MouseButtonType.Left, false, 1, CefEventFlags.None);
Thread.Sleep(15);
}
public void MouseLeftUp(ChromiumWebBrowser _browser, int x, int y)
{
_browser.GetBrowser().GetHost()
.SendMouseClickEvent(x, y, MouseButtonType.Left, true, 1, CefEventFlags.None);
Thread.Sleep(15);
}
Here is the code I use to figure out the element position.
- Code: Select all
function findPos(el)
{
const rect = el.getBoundingClientRect();
return {
X: rect.left + window.scrollX + (rect.width / 2),
Y: rect.top + window.scrollY + (rect.height / 2)
};
}
function findScroll(obj)
{
var curleft = 0;
var curtop = 0;
if (obj.parentElement)
{
do
{
curleft += obj.scrollLeft;
curtop += obj.scrollTop;
} while (obj = obj.parentElement);
return { X: curleft,Y: curtop};
}
}
I hope someone has some good advice to share because these 2 days of struggle have been frustrating.
![Wink ;)](./images/smilies/icon_e_wink.gif)