Mouse move in a circle whoes center is ....

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Jameso_0
Posts: 52
Joined: 14 Oct 2015, 22:37

Mouse move in a circle whoes center is ....

05 Nov 2015, 12:22

move mouse in a circle
center = 800,450 ( my screen's center, it never changes )
radius = 50

help me with this script
kon
Posts: 1756
Joined: 29 Sep 2013, 17:11

Re: Mouse move in a circle whoes center is ....

05 Nov 2015, 13:27

Maybe:

Code: Select all

for i, Point in GeneratePoints(800, 450, 50) {
    MouseMove, Point.1, Point.2, 0
}

; GeneratePoints - generates an array of points on a circle.
; PointsN = number of points
GeneratePoints(CentX, CentY, Radius, PointsN := 25) {
    Points := [], PI := 4 * ATan(1), Step := PI / (PointsN // 2), Quadrant := PointsN // 4
    Loop, % Quadrant {
        Rads := A_Index * Step
        X := Cos(Rads) * Radius
        Y := Sin(Rads) * Radius
        Points[A_Index] := [CentX + X, CentY + Y]
        Points[(Quadrant * 2) - A_Index] := [CentX - X, CentY + Y]
        Points[A_Index + (Quadrant * 2)] := [CentX - X, CentY - Y]
        Points[(Quadrant * 4) - A_Index ] := [CentX + X, CentY - Y]
    }
    return Points
}
I hope this helps :)
wolf_II
Posts: 2688
Joined: 08 Feb 2015, 20:55

Re: Mouse move in a circle whoes center is ....

05 Nov 2015, 13:28

another one:

Code: Select all

CoordMode, Mouse, Screen
MoveMouse_Circle(800, 450, 50, 36) ; use 36 steps


;-------------------------------------------------------------------------------
MoveMouse_Circle(cx, cy, r, s) { ; move mouse in a circle
;-------------------------------------------------------------------------------
    $Pi := 4 * ATan(1)
    MouseMove, cx + r, cy, 0
    Loop, % s ; number of steps
        MouseMove, cx + r * Cos(A_Index * 2 * $Pi / s)
                 , cy + r * Sin(A_Index * 2 * $Pi / s)
}
User avatar
Xtra
Posts: 2750
Joined: 02 Oct 2015, 12:15

Re: Mouse move in a circle whoes center is ....

06 Nov 2015, 03:18

Code: Select all

CoordMode, Mouse, Screen
SetBatchLines -1

len   := 50                             ; Radius
wPos  := A_ScreenWidth/2     ; X center
hPos  := A_ScreenHeight/2    ; Y center
;steps: Slower << 360,180,120,90,72,60,45,36,30,24,18,10,9 >> Faster.
steps := 9 
point := (360/steps)

1::
Loop % steps
{
    GetPosFromAngle(mx,my,wPos,hPos,len,A_Index*point)
    MouseMove,mx,my,0
}
return

GetPosFromAngle(ByRef x2,ByRef y2,x1,y1,len,ang)
{   ; MasonJar13
    ang := (ang-90) * 0.0174532925
    x2 := x1 + len * cos(ang)
    y2 := y1 + len * sin(ang)
}
Jameso_0
Posts: 52
Joined: 14 Oct 2015, 22:37

Re: Mouse move in a circle whoes center is ....

08 Mar 2016, 02:01

Oops ! I didn't replay to your answers ? I am sorry in that case!

I tried all the scripts and all works like charm !

Thanks for quick replay. U guys are genious !
:)
User avatar
boardtc
Posts: 48
Joined: 12 Feb 2016, 10:13
Contact:

Re: Mouse move in a circle whoes center is ....

26 Sep 2022, 16:11

Has anyone tried hooking one of these script up to a shortcut? Once I have selected the freeform snip in the windows snipping tool I would like to be able to run this code. An issue is that the circle will be of varying size depending on the snip. ANy advice appreciated.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: JKJadan, peter_ahk and 279 guests