# Help! Mouse move code?



## Kale542 (Mar 16, 2008)

Okay, I need to know what coding system I need to get to make a program that auto-left clicks once, then moves the mouse, right clicks, moves the mouse, left clicks, goes back to the original spot and loops that whole thing. Please give me a system and code to do that if possible,

Thanks!!


----------



## ClayC (Jul 25, 2008)

I didn't quite understand this but I think my post will help you alot with it

http://forums.techguy.org/software-development/734074-visual-basic-2008-form-moving.html

what that code does is turn on the move code so on mousemove it just moves the code when you release it will turn off the whole thing and nothing will happen, I hope this is good enough for you... if you want more to it and you don't know how to do it please feel free to repost here


----------



## Kale542 (Mar 16, 2008)

Okay, I'm not tech smart enough to know what that mens, a simpler explanation please? 

Would you do: 

//Rapid click//

mousePosition.X = __ 
mousePosition.Y = __

//Then i need it to right click.....?//

mousePosition.X = __ 
mousePosition.Y = __

//Left click//

//do that 28 times (right click, move left click)//

mousePosition.X = __ 
mousePosition.Y = __

//loop the whole thing//


----------



## stantley (May 22, 2005)

It would be much easier to do it with AutoHotkey, a freeware scripting tool.

To move the mouse to a certain position the command is MouseMove, X, Y
You determine the xy coordinates with a program that comes with AutoHotkey called Window Spy.

To click the mouse at a certain position the command is MouseClick, WhichButton, X, Y, ClickCount

To loop 28 times is

Loop, 28
{

(all the commands)

}


----------



## ClayC (Jul 25, 2008)

yeah it's easier to just code it yourself it's easy to set the mouse position

use the New System.Drawing.Point(x,y) to set the mouse position even the form or an item in the form  for size use New System.Drawing.Size(width, height)


----------



## Kale542 (Mar 16, 2008)

stanley, is that vbs or what that you are talking about?
Quoting Stanley:
"To move the mouse to a certain position the command is MouseMove, X, Y
You determine the xy coordinates with a program that comes with AutoHotkey called Window Spy.

To click the mouse at a certain position the command is MouseClick, WhichButton, X, Y, ClickCount

To loop 28 times is

Loop, 28
{

(all the commands)

}"


----------



## stantley (May 22, 2005)

No, it's AutoHotkey, similar to VBS but much easier syntax and easier to learn. Check out the link I gave you.

I use it for all sorts of things. When I first got it I was looking for something to do simple keyboard and mouse macros. Then I was doing all sorts of 'gamebots', automating game play. I wrote one for Text Twist that fills in all the words in a couple seconds. Lately I've been doing some programs that read, write and sort files. 

But anyway, you can use it for simple tasks and as you get more experience very complicated programs.


----------



## ClayC (Jul 25, 2008)

umm can you send it to me too? cause I am trying to build a bot for 2moons and Dekaron but I can't with VB only 

well thanks


----------



## stantley (May 22, 2005)

Go here: http://www.autohotkey.com/, download and install the program.

Then go through the Quick-start Tutorial. It will give you a few simple scripts to give you the basics on how it all works. Run a few of those to get your feet wet and then dive right in.


----------



## ClayC (Jul 25, 2008)

yeah I noticed it's for C++ and not VB 2008 Express Edition.... I'm gonna try maybe I can somehow make it work with VB but idk we'll see

Thanks for the link

--- EDIT ---

from what i saw in the Start Tutorial it only has 1 good thing that I don't know how to do in VB itself, that's sending mouse clicks and keystrokes but the rest I know how to...


----------



## Kale542 (Mar 16, 2008)

okay, I made the script, and it works well, but theres just one problem: I need you to be able to just press ctrl+x and it quits, at any given time


----------



## stantley (May 22, 2005)

There are many ways to do that but the easiest I've found is to reload the script. So after the last return of your current script put:

^x::
Reload
Return 

or if you want it to display a message:

^x::
MsgBox, Stopping
Reload
Return

But you might want to pick a different hotkey since ctrl x is the Windows cut command.


----------



## Kale542 (Mar 16, 2008)

but where do i put that code? at the bottom, inbetween every line, at the top...?


----------



## stantley (May 22, 2005)

stantley said:


> after the last return of your current script


At the bottom.


----------



## Kale542 (Mar 16, 2008)

but that only restarts the script, I need it to exitApp


----------



## Kale542 (Mar 16, 2008)

nevermind, I fixed it myself


----------

