Sign in to follow this  
Followers 0
stryderjess

Noob script help please

8 posts in this topic

I'm just learning how to make scripts, and right now I am trying to make a script that makes the mouse move slightly to the right and left click every time I press the z key. I'm trying to learn this on my own and so far I came up with

HotKeySet("{z}","moveclick")

Func moveclick()

MouseGetPos()

MouseMove($array[0]+20,$array[1],0)

MouseClick("left")

EndFunc

But it doesnt seem to be working and I've been trying to figure this out on my own, but like I said I'm a noob :) Any help would be greatly appreciated.

Share this post


Link to post
Share on other sites



Hi! Welcome to the forums. :)

Please create a better thread title next time, people tend to ignore threads were the title doesn't give a hint about the problem.

Your problem is easy, it's because the script exits immediately, add this:

While Sleep(10)
WEnd

And it will work great :lmao:


Broken link? PM me and I'll send you the file!

Share this post


Link to post
Share on other sites

I had a problem understanding the while + sleep thing at first too :think:

But the computer reads your script from top to bottom of what you tell it to do. It sets the hotkey , than moves on.

Since your hotkey calls upon your function , the computer skips over that.... and ends the program since theres nothing for it to do.

The Sleep(10) is there in the while loop to give the program something to do while it waits for you to call upon your created function :).

Note: I just felt the need to explain that because that was one of the things that gave me trouble in my newb days of autoit :lmao:.

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Hi! Welcome to the forums. :)

Please create a better thread title next time, people tend to ignore threads were the title doesn't give a hint about the problem.

Your problem is easy, it's because the script exits immediately, add this:

While Sleep(10)
WEnd

And it will work great :lmao:

Thanks very much for the tips, I will definitely be more descriptive in the future on the subject titles on my threads, and your code helped my script make a little progress although I'm not sure how(though thanks for the insight Drew). Now I'm having a new problem however in that I'm getting a error message that I'm not declaring the variable on line 4 saying

Error: Variable used without being declared.

Any ideas how to fix that?

Edited by stryderjess

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

I'm just learning how to make scripts, and right now I am trying to make a script that makes the mouse move slightly to the right and left click every time I press the z key. I'm trying to learn this on my own and so far I came up with

HotKeySet("{z}","moveclick")

Func moveclick()

MouseGetPos()

MouseMove($array[0]+20,$array[1],0)

MouseClick("left")

EndFunc

But it doesnt seem to be working and I've been trying to figure this out on my own, but like I said I'm a noob :) Any help would be greatly appreciated.

Try This:

HotKeySet("z","moveclick")

While 1
        Sleep( 10 )
WEnd

Func moveclick()
    $array = MouseGetPos()
    MouseClick("left", $array[0]+20, $array[1], 1, 0)
EndFunc

Reasoning:

MouseGetPos returns a 2 array variable , so you need to give it a variable to use. That is why I put $array = MouseGetPos() ... ( To "declare" it. )

And instead of having MouseClick("left") you could do this:

$array = MouseGetPos()

MouseClick("left", $array[0]+20, $array[1], 1, 0)

Its the same thing but I combined the mouse movement with the mouseclick. Now it will move there and click all in 1 go.

Edited by Drew

Share this post


Link to post
Share on other sites

Awesome thanks a lot. It works beautifully. Hopefully I'll start getting the hang of this a little better :lmao: Your help was much appreciated. :)

Share this post


Link to post
Share on other sites

Thats what the Forums are here for to get help when you need it, dont be shy to ask BUT BE SENSIBLE on topic titles and that jazz USE SEARCH lol but yeah forums ARE here for a reason :)

Share this post


Link to post
Share on other sites

Thats why I love em :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0