# How to do

## Recommended Posts

Ok heres what im try to achieve.

Based on the amount the user enters into the input box the script will run that many times.

Now the script has to move the mouse down -2 y every time based on the amount entered and x has to remain the same. How can i achieve this without making a incredibly long IF statement?

##### Share on other sites

Ok heres what im try to achieve.

Based on the amount the user enters into the input box the script will run that many times.

Now the script has to move the mouse down -2 y every time based on the amount entered and x has to remain the same. How can i achieve this without making a incredibly long IF statement?

This does what you say... (I'm assuming by -2 y you mean down? if not change the + to -)

```\$Num = InputBox("Runs", "How many times?", 1)
\$Start = MouseGetPos()
For \$i = 1 To \$Num
MouseMove(\$Start[0], \$Start[1] + 2)
\$Start = MouseGetPos()
Next```

RAWR! I'm hungry :( Feed the panda squirrle

##### Share on other sites

Good example above.

To expand on that example, you may need to block user input so they may not interfere with the mouse moves. Also, we should check if the mouse will hit the bottom of the screen before the looping is done, and if so, change the amount of loops to what would hit the bottom of the screen.

```#RequireAdmin ; For BlockInput()
\$Num = InputBox("Runs", "How many times?", 1)
BlockInput(1) ; Block user control of mouse and keyboard
;~ Check if \$num is set too high and will cause the mouse to hit the end of the screen early.
If MouseGetPos(1) + (\$Num * 2) > @DesktopHeight Then \$Num = Int((@DesktopHeight - MouseGetPos(1)) / 2)
For \$i = 1 To \$Num
MouseMove(MouseGetPos(0), MouseGetPos(1) + 2)
Next
BlockInput(0)```

Thnx alot

## Create an account

Register a new account