Click here to Skip to main content
15,886,518 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi people.
How may I VISUALLY move the mouse cursor to a specific position via Selenium in VBA Excel?

If you are going to ask me that what does it matter to see visually the cursor, I should answer that it is because I am using Magnifier. I should move the mouse to any place to see that in the magnifier window. So I want every mouse actions in my Selenium project, able to see in magnifier window.

What I have tried:

I want to move the cursor to 5,10. But the mouse cursor doesn't move visually.
Sub VisuallyCursorMove()
    dim Driver as Selenium.ChromeDriver
    Set Driver = New Selenium.ChromeDriver
    Driver.Start
    Driver.Get "http://www.yahoo.com"
    Driver.Actions.MoveByOffset(5, 10).Perform
End Sub
Posted
Comments
CHill60 5-May-23 3:52am    
You could put the mouse move into a loop and move it towards it's final destination in small increments
Sh.H. 5-May-23 7:48am    
Would you please kindly explain?
CHill60 5-May-23 7:53am    
I'm not familiar with Selenium but in principle it would be
...
Driver.Get etc
Dim i As Integer
For i = 1 To 10
     Driver.Actions.MoveByOffset(5,1).Perform
Next<pre>I.e. only move the mouse by 1 point but do it 10 times in a loop so it's the equivalent of <pre>Driver.Actions.MoveByOffset(5,10).Perform
Sh.H. 5-May-23 13:41pm    
No. Doesn't work!
In selenium, the code does not move the shape of mouse individually.
So that was why I asked this question.
I hope someone helps me.
[no name] 7-May-23 8:19am    
You need a "delay". Either "sleep" after each incremental move; or use a timer events for moving. You may have to "refresh" the display after each move. Protype by trying to move the mouse with arrow keys to see if you even know how to move the mouse.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900