Continuous drag in circle

Asked by Alex

I'm looking for a way to use dragdrop but without the drop to continuously drag in a circle? So instead of specifying point A and point B, you'd specify point A, direction, and rotation radius.

i.e. one might like to monitor CPU usage while continuously rotating a 3D CAD drawing.

Thanks for your help.

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
Alex
Solved:
Last query:
Last reply:
Revision history for this message
Roman Podolyan (podolyan-roman) said :
#1

Try to use low-level mouse functions.

Look here: http://doc.sikuli.org/region.html#low-level-mouse-and-keyboard-actions , and experiment with mouseDown and mouseMove . mouseDown allows to drug how long you want, and I think that using mouseMove you can "interpolate" circling quite well .

Revision history for this message
Roman Podolyan (podolyan-roman) said :
#2

The hardest part is how to get the array of vectors for moving mouse with mouseMove, but I think it can be solved too:

Choose radius R you want for circling
Choose center point of circle (X,Y).
Now you need to draw 4 quarters of circle.
Let's start from X,Y+R and go clockwise.
Going from point X+1,Y+R down, we are looking for first point on X+1 vertical which will be close to (X,Y) than R.
When found, we can record move "vector", required for moving with mouseMove to this point from (X,Y+R).
Than doing the same for X+2 vertical from point X+2,Y+R, and so on...
In the end we will get array of vectors, moving us from X,Y+R to X+R,Y as close to R-radius circle as we can be.
Than we can calculate waypoints and vectors to move from X+R,Y to X,Y-R , and so on

Got the idea?

It's just dirty solution, maybe someone will post better way for that.

Revision history for this message
Alex (arevelos) said :
#3

Thanks Roman. I will do some experimenting this weekend and let you know the outcome.

Thanks again.

Revision history for this message
RaiMan (raimund-hocke) said :
#4

Yippie, a challenge :-)))

Settings.MoveMouseDelay=0
import math as m
pi = m.pi

circle = []
for n in range(0, 370, 1):
    y = int(100*m.sin(m.radians(n)))
    x = int(100*m.cos(m.radians(n)))
    circle.append(Location(200+x, 200+y))

for p in circle: hover(p)

makes a circle with radius 100 pixel at center (200,200) stepping with a stepping of 1 degree.
this is interestingly slow.

the smaller the circle, the larger the stepping might be and vice-versa.

Revision history for this message
Alex (arevelos) said :
#5

The solution worked perfectly. I used RaiMan's code in addition to lower level mouse operations (mouseDown(Button.LEFT) & mouseUp(Button.LEFT)) suggested by Roman. The speed is actually ideal for me, ~ 2 seconds per rotation.

Thank you both for your input!