Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Looping script to move the mouse up and down


  • Please log in to reply
25 replies to this topic
Centigrade
  • Members
  • 11 posts
  • Last active: Jan 17 2015 04:44 PM
  • Joined: 14 Jan 2015
 

 

toggle:=0
CoordMode, Mouse, Screen
 
F8::
toggle!:=toggle
If toggle
{
SetTimer, Clicker, 1000
SetTimer, Mover, 7100
MouseGetPos, X, Y ; Not in the Mover Timer because the drift could be caused by resetting these values constantly, but the issue you describe isn't fully normal
}
If !toggle
{
SetTimer, Clicker, Off
SetTimer, Move, Off
}
return
 
Clicker:
Click
return
 
Mover:
MouseMove, 0, 20,,R
Sleep 2000
MouseMove, %X%, %Y%
return

 

How does this work for you?

 

Error at line 5.

 

Line Text: toggle!:=toggle

Error: This line does not contain a recognized action.

 

The program will exit.



GEV
  • Members
  • 1364 posts
  • Last active:
  • Joined: 23 Oct 2013

Install the newest AHK version



Centigrade
  • Members
  • 11 posts
  • Last active: Jan 17 2015 04:44 PM
  • Joined: 14 Jan 2015

I am using the latest version (I followed your link just to be sure). Same error. Is there perhaps a misplaced punctuation mark?

 

 

e1: I am thinking perhaps line 5 should read,

toggle:=!toggle

 

 

e2: nope, that made every line after it stop working.



GEV
  • Members
  • 1364 posts
  • Last active:
  • Joined: 23 Oct 2013
toggle:=0
CoordMode, Mouse, Screen

F8::
if toggle := !toggle
{
SetTimer, Clicker, 1000
SetTimer, Mover, 7100
MouseGetPos, X, Y ; Not in the Mover Timer because the drift could be caused by resetting these values constantly, but the issue you describe isn't fully normal
}
else
{
SetTimer, Clicker, Off
SetTimer, Mover, Off
}
return

Clicker:
Click
return

Mover:
MouseMove, 0, 20,,R
Sleep 2000
MouseMove, %X%, %Y%
return


Centigrade
  • Members
  • 11 posts
  • Last active: Jan 17 2015 04:44 PM
  • Joined: 14 Jan 2015

Script now properly toggles; attacks once per second.

 

Script now drifts downward exclusively and does not properly reset to a neutral position.

 

This script is worse than a previously suggested script, which frequently moved between Position A and Position B but caused Position A to drift upward over time; instead, this script exclusively drifts downward and never returns to the neutral position.



Exaskryz
  • Members
  • 3249 posts
  • Last active: Nov 20 2015 05:30 AM
  • Joined: 23 Aug 2012

Well, I guess one way you can try this is the drift may be the exact same with each step.

 

Going back a few scripts, we could do the relative ones:

 

MouseMove, 0, -20,,R
MouseMove, 0, 19,,R

 

(I noticed that I used positive 20 in the bigger completely script (which had a typo that was resolved), which I think moves it downwards.)

 

You had experienced up drift when the values were -20 and 20 I believe, so let's just make the downdrift, which I think is in the positive direction, less.



Centigrade
  • Members
  • 11 posts
  • Last active: Jan 17 2015 04:44 PM
  • Joined: 14 Jan 2015

Can you paste a complete script using that modification? I am not sure if (or how) that is meant to be combined with your previously posted script. Was it meant to be combined with GEV's script?



TravisQ
  • Members
  • 86 posts
  • Last active: Jun 26 2015 05:39 PM
  • Joined: 25 Oct 2014
F8::goto % (t:=!t) ? "start" : "stop"
start:
        MouseGetPos,X,Y
	SetTimer,exp,-1
  return
stop:
	SetTimer,exp,Off
  return
exp:
	SetTimer,exp,5000
	MouseMove,% X,% Y-20
	Click
	Sleep,1000
	Click
	Sleep,1000
	MouseMove,% X,% Y
	Click
	Sleep,1000
	Click
	Sleep,1000
	Click
  return
Esc::ExitApp

another try :)



Centigrade
  • Members
  • 11 posts
  • Last active: Jan 17 2015 04:44 PM
  • Joined: 14 Jan 2015
F8::goto % (t:=!t) ? "start" : "stop"
start:
        MouseGetPos,X,Y
	SetTimer,exp,-1
  return
stop:
	SetTimer,exp,Off
  return
exp:
	SetTimer,exp,5000
	MouseMove,% X,% Y-20
	Click
	Sleep,1000
	Click
	Sleep,1000
	MouseMove,% X,% Y
	Click
	Sleep,1000
	Click
	Sleep,1000
	Click
  return
Esc::ExitApp

another try :)

 

Does not toggle with the same keybind (requires exiting the script to pause).

Drifts exclusively up rather than shifting between up and down.



wuvixx
  • Members
  • 140 posts
  • Last active: Mar 12 2015 10:31 AM
  • Joined: 15 Sep 2014

Excuse me if I misunderstood what you were requesting. Take a look at this.

#MaxHotkeysPerInterval 2

F8::
toggle := !toggle
if (toggle)
	SetTimer, ClickSpam, 1000 ; 1 sec
if (!toggle)
{
	SetTimer, ClickSpam, OFF
	SetTimer, MoveIt, OFF
	SetTimer, MoveIt2, OFF
}
return

ClickSpam:
Click
if (!tEnabled)
{
	SetTimer, MoveIt, 5000 ; 5 seconds
	tEnabled := 1
}
return

MoveIt:
MouseGetPos, xpos, ypos
MouseMove, 0, -20, , R ; Only by 20 pixels upwards
SetTimer, MoveIt2, -5000
SetTimer, MoveIt, OFF
return

MoveIt2:
MouseMove, % xpos, % ypos
tEnabled := 0
return

F9::Pause

F8 can be pressed again to toggle and F9 is used to pause.


“Je suis Charlie”


bigdeoz
  • Members
  • 148 posts
  • Last active: Feb 04 2015 03:43 PM
  • Joined: 06 Sep 2013

something like this could do?

 

tell me what is wrong

#SingleInstance, force
#Persistent
CoordMode, Mouse, Screen

F8::
MouseGetPos, st_x, st_y
n_y := st_y
stop := st_y - 100 
toggle := !toggle
SetTimer, upper, 250

return

upper:
while (toggle)
{
	Click
	ToolTip %toggle% _ %st_x%  _ %st_y% _ %n_y% _ %stop%
	n_y -= 1
	MouseMove,st_x,n_y,R
	IF n_y = %stop% ; = 5 sec
		gosub, downer
}
return

downer:
SetTimer, upper, Off
MouseMove, st_x, st_y
n_y := st_y
Sleep, 500
SetTimer, upper, On
return

F9::Pause

D.z