When executing the code. This SLIDER is actually clicked on because the slider changes value a bit.
I'm afraid not.
If this slider is indeed clicked, then when our mouse moves left and right, the slider will move with it, even if we did not click the slider (because we have clicked through the code).
But the current code does not seem to have this behavior, I still need to click on this slider and then move left and right.
After some testing, I found the cause of the problem.
The Y value of the position we need to pass to SendMouseClickEvent is shown in image 1. It is the position of the slider relative to the control. As we slide the wheel, it will change.
But the Y value obtained by the current JS code is shown in image 2. The position of the slider relative to the top of this website is fixed (as long as we don’t change the size of the page, if we adjust the page very narrowly,
Then the control will move down because of the re-formatting of the page).
So this code does not actually click the slider, which leads to the current confusion.
To capture the slider accurately, I modified the code. After clicking the button, hover the cursor on the slider, and then you can see the slider move with the execution of SendMouseMoveEvent.
public Form1()
{
InitializeComponent();
}
private ChromiumWebBrowser browser;//CefSharp brows
private void Form1_Load(object sender, EventArgs e)
{
browser = new ChromiumWebBrowser("https://uniswapv3.flipsidecrypto.com")
{
Dock = DockStyle.Fill,
};
this.Controls.Add(browser);
}
private void button1_Click(object sender, EventArgs e) { new Thread(moveSlideControl).Start(); }
void moveSlideControl()
{
//I did it deliberately, it cannot be submitted when S*leep() is included in the code, you should delete the *.
Thread.S*leep(2000);
Point ptCursor = new Point(0, 0);
this.Invoke(new Action(() =>
{
ptCursor = Cursor.Position;
ptCursor = PointToClient(ptCursor);
}));
MouseLeftUp(ptCursor.X, ptCursor.Y);
}
private void MouseLeftUp(int v1, int v2)
{
var host = browser.GetBrowser().GetHost();
host.SendMouseClickEvent(v1, v2, MouseButtonType.Left, false, 1, CefEventFlags.None);
for (int i = 0; i < 7; i++)
{
v1 = v1 + i * 2;
host.SendMouseMoveEvent(v1, v2, false, CefEventFlags.LeftMouseButton);//Move the mouse
Thread.S*leep(1000);
}
}
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.