AutoHotkey Community

It is currently May 27th, 2012, 1:16 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 42 posts ]  Go to page Previous  1, 2, 3
Author Message
 Post subject:
PostPosted: July 3rd, 2008, 1:13 pm 
Offline

Joined: July 2nd, 2008, 3:59 pm
Posts: 62
it doesnt center, it centers the fourth point which is bottom right of where should be correct center position
----
nvm got it to work by changing to

Code:
MouseClick, Left, X*Step + MouseX + 50, Y*Step + MouseY + 50


thanks again


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 3rd, 2008, 1:59 pm 
Offline

Joined: July 2nd, 2008, 3:59 pm
Posts: 62
ok, a few steps forward... :x
how can it skip clicking if the point is on vertical line of center position?
i touched a bit and changed to this

Code:
F1::
MouseGetPos, MouseX, MouseY
Step := 50 ; the distance between one point and the next
X := -1, Y := -1
Loop
{
   mark := Mod(A_Index,2) ? "X" : "Y"
   sign := Mod(A_Index//2,2)*2-1
   Loop % Ceil(A_Index/2)
   {
 %mark% += sign
 if MouseX := X*Step + MouseX + 50
 break
 else if MouseY := Y*Step + MouseY + 50
 break
 else
 MouseClick, Left, X*Step + MouseX + 50, Y*Step + MouseY + 50, 1, 0

   }
   GetKeyState, state, F1, P
   if state = U
   break
   else
   continue
}
return

esc::reload


whats the problem here? it should skip the ones on vertical line.. hmm..


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 3rd, 2008, 2:38 pm 
Offline

Joined: September 14th, 2007, 4:51 am
Posts: 220
Code:
Esc::ExitApp

F1::
{
rdir:=2
udir:=3
ldir:=3
ddir:=2
MouseGetPos, x, y
x:=x-50
y:=y-50
Click %x% %y%
loop
  {
     loop %ddir%
       {
       y:=y+50
       Click %x% %y%
       }
    ddir:=ddir+2
    loop %rdir%
      {
      x:=x+50
      Click %x% %y%
      }
    rdir:=rdir+2
    loop %udir%
      {
      y:=y-50
      Click %x% %y%
      }
    udir:=udir+2
    loop %ldir%
      {
      x:=x-50
      Click %x% %y%
      }
    ldir:=ldir+2
  }
}return


With this you have access to each side...
just add a conditional before the "Click" and that should do the trick.

_________________
Image Search&Replace

Don't use cannon to kill mosquito


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 3rd, 2008, 2:45 pm 
Offline

Joined: July 2nd, 2008, 3:59 pm
Posts: 62
any idea to skip dots vertical to center position?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 3rd, 2008, 2:47 pm 
Offline

Joined: September 14th, 2007, 4:51 am
Posts: 220
Code:
(x=0)?continue:Click %x% %y%


something like that...

_________________
Image Search&Replace

Don't use cannon to kill mosquito


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 3rd, 2008, 3:03 pm 
Offline

Joined: September 14th, 2007, 4:51 am
Posts: 220
Code:
SetBatchLines, -1
Esc::ExitApp

F1::
{
rdir:=2
udir:=3
ldir:=3
ddir:=2
MouseGetPos, x, y
xfactor:=x
x:=x-50
y:=y-50
if (x!=xfactor)
   Click %x% %y%
loop
  {
     loop %ddir%
      {
      y:=y+50
      if (x!=xfactor)
         Click %x% %y%
      }
    ddir:=ddir+2
    loop %rdir%
      {
      x:=x+50
      if (x!=xfactor)
         Click %x% %y%
      }
    rdir:=rdir+2
    loop %udir%
      {
      y:=y-50
      if (x!=xfactor)
         Click %x% %y%
      }
    udir:=udir+2
    loop %ldir%
      {
      x:=x-50
      if (x!=xfactor)
         Click %x% %y%
      }
    ldir:=ldir+2
  }
}return

_________________
Image Search&Replace

Don't use cannon to kill mosquito


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 3rd, 2008, 3:53 pm 
Offline

Joined: July 2nd, 2008, 3:59 pm
Posts: 62
ok i also added skipping for dots verticaly to center in y coordinate

now my goal is almost there..
i want it to hold lbutton down at the current position, then mousemove to an inner point, offset by 50,50 from the current position then release there.
so it is going to drag range of 50,50 toward center position from current position, each time when it gets to new position.


below doesnt work

Code:
if X > centerX, Y > centerY
MouseClickDrag, left, X, Y, -50, -50 , 0, R

else if X > centerX, Y < centerY
MouseClickDrag, left, X, Y, -50, +50 , 0, R

else if X < centerX, Y > centerY
MouseClickDrag, left, X, Y, +50, -50 , 0, R

else if X < centerX, Y < centerY
MouseClickDrag, left, X, Y, +50, +50 , 0, R


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 4th, 2008, 6:43 am 
Offline

Joined: July 2nd, 2008, 3:59 pm
Posts: 62
hmm.. still cant get it to work :S


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 5th, 2008, 1:04 pm 
Offline

Joined: July 2nd, 2008, 3:59 pm
Posts: 62
ok finally got it to work, thanks to everyone who has supported.

Code:
Esc::
reload
return

$F1::
MouseGetPos, CenterX, CenterY
rdir:=2
udir:=3
ldir:=3
ddir:=2
MouseGetPos, x, y
xfactor:=x
yfactor:=y
x:=x-60
y:=y-60
MouseClickDrag, left,-200, -200, 200, 200, 0, R
MouseClick, right,centerx,centery,1,0
MouseClickDrag, left,-200, 0, 200, 200, 0, R
MouseClick, right,centerx,centery,1,0
MouseClickDrag, left, 0, 0, 200, 200, 0, R
MouseClick, right,centerx,centery,1,0
MouseClickDrag, left, 0, -200, 200, 200, 0, R
MouseClick, right,centerx,centery,1,0
MouseMove, X, Y, 0
MouseClickDrag, left, 0, 0, 100, 100, 0, R
MouseClick, right,centerx,centery,1,0
loop
{
     
   loop %ddir%
   {
      y:=y+60
      if (x!=xfactor && y!=yfactor)
      GoSub, Drag

      GetKeyState, state, F1, P
      if state = U
      return
         else if (x > 900 || x < 100 || y > 600 || y < 100)
         return
         else continue
         } ;;dir
ddir:=ddir+2




   loop %rdir%
   {
      x:=x+60
      if (x!=xfactor && y!=yfactor)
      GoSub, Drag

      GetKeyState, state, F1, P
      if state = U
      return
         else if (x > 900 || x < 100 || y > 600 || y < 100)
         return
         else continue
      }
rdir:=rdir+2


   loop %udir%
   {
      y:=y-60
      if (x!=xfactor && y!=yfactor)
      GoSub, Drag

      GetKeyState, state, F1, P
      if state = U
      return
         else if (x > 900 || x < 100 || y > 600 || y < 100)
         return
         else continue
      }
udir:=udir+2


   loop %ldir%
   {

      x:=x-60
      if (x!=xfactor && y!=yfactor)
      GoSub, Drag

      GetKeyState, state, F1, P
      if state = U
      return
         else if (x > 900 || x < 100 || y > 600 || y < 100)
         return
         else continue
         }
ldir:=ldir+2


}return

Drag:
if (x>centerx && y>centery)
{
MouseMove, X, Y, 0
MouseClickDrag, left, 0, 0, -130, -100, 0, R
MouseClick, right,centerx,centery,1,0
}
else if (x>centerx && y<centery)
{
MouseMove, X, Y, 0
MouseClickDrag, left, 0, 0, -130, 100, 0, R
MouseClick, right,centerx,centery,1,0
}
else if (x<centerx && y>centery)
{
MouseMove, X, Y, 0
MouseClickDrag, left, 0, 0, 130, -100, 0, R
MouseClick, right,centerx,centery,1,0
}
else if (x<centerx && y<centery)
{
MouseMove, X, Y, 0
MouseClickDrag, left, 0, 0, 130, 100, 0, R
MouseClick, right,centerx,centery,1,0
}
return


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 6th, 2008, 2:48 pm 
Offline

Joined: May 1st, 2007, 8:36 pm
Posts: 83
Location: The Netherlands
Though many have already provided solutions, I wanted to contribute something too. It was fun to do. The result is a function that uses math to calculate the coordinates of a point on the square spiral (couldn't think of a better name :P) and returns them. Because it does not add values to previous coordinates, it can calculate every point without having to go through numerous iterations of a loop. (of course it does need a loop to draw a full spiral) Also, you can specify the starting direction, the size of the gap between lines and the direction of the rotation. 8)

Below is the function with an example. Open a new window in paint and watch it draw! :wink: (press Escape to exit)
Code:
SetBatchLines, -1

WinWaitActive, Untitled
Sleep, 1000
WinGetActiveStats, t, w, h, x, y
MouseMove, w/2, h/2, 0
Send, {LButton down}
Loop
{
   r := SquareSpiral(A_Index, 50, 2, -1)
   StringSplit, r, r, `,
   MouseMove, w/2 + r1, h/2 + r2, 0
   Sleep, 100
}


Return


Escape::
Send, {LButton up}
ExitApp
Return

;SquareSpiral
;   Information:
;   Description   Returns coordinates of points on a square spiral.
;   Author        Wouther
;
;   Parameters:
;   n   The number of the point. (obligatory)
;   s   Distance between lines. (default is 1 px)
;   d   Starting direction. Right is 1, down is 2, left is 3 and up is 4. (default is right)
;   r   Direction of rotation. Counterclockwise is -1 and Clockwise = 1. (default is counterclockwise)
;
;   Returns:
;   x,y   Comma-seperated coordinates of the 'n'-th point.
SquareSpiral(n, s = 1, d = 1, r = -1)
{
   f := Mod(n, 4)

   x := s*Ceil(n/4)
   y := s*Ceil(n/4)

   x *= (f = 1 || f = 2) ? -1 : 1
   y *= (f = 2 || f = 3) ? -1 : 1

   y -= (f = 1) ? s : 0

   m := (d = 3 || d = 4) ? -1*r : r
   a := (d = 1 || d = 3) ? "y" : "x"
   %a% += (f = 1) ? m*s

   Return x . "," . y
}
Furthermore, because it's a function returning the coordinates, the part of calculating and the actual script are seperated.

_________________
Printing css/html-formatted text


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 6th, 2008, 3:56 pm 
Offline

Joined: July 2nd, 2008, 3:59 pm
Posts: 62
cool, mine works a bit slow in full screen window, was wondering its because of the long code. ill try editing yours and see if that would work better. thanks for it :)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 6th, 2008, 6:31 pm 
Offline

Joined: May 1st, 2007, 8:36 pm
Posts: 83
Location: The Netherlands
You could try removing the 'Sleep, 100' in the loop. :P I placed it there because when the square spiral got very big (almost my entire screen) and if you set the gap very small, The Gimp (probably also Paint, I don't know) couldn't handle the speed and sometimes skipped one point, resulting in diagonal lines through the spiral. :wink:

_________________
Printing css/html-formatted text


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 42 posts ]  Go to page Previous  1, 2, 3

All times are UTC [ DST ]


Who is online

Users browsing this forum: Amandaville, Bing [Bot], BrandonHotkey, chaosad, Yahoo [Bot] and 24 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group