Jump to content

A smoother MouseMove


the DtTvB
 Share

Recommended Posts

Hi.

I just made this code, this code moves the mouse more smoothly.

It smoothly starts, and smoothly ends. This function also do some random curves, but it is still smooth!

The ease in function.

Slowly increases the value, used in animations.

$i = number between 0 and 1 representing the animation position.

$sm = smoothness, if set to 1, it will be a linear animation.

Posted Image

; Ease in function
func __calci1($i, $sm)
    return $i ^ $sm;
endFuncoÝ÷ Ù´áyæ¬z)èº×îËb¢ÛRȧØ^y«v§uæ¬z­¶+^j÷«Êɨ¢ØZ)*'h!¶Úþ-uÚh¶îrG­r¿jVîÏç׿?éeéàýæ¬z)èºØ"ø¦«­¢+ØìÍ¥¸½ÕÐչѥ½¸)Õ¹}}±¤ ÀÌØí¤°ÀÌØíÍ´¤(%¥ ÀÌØí¤±ÐìÀ¸Ô¤Ñ¡¸($%ÉÑÕɸ}}±¤Ä ÀÌØí¤¨È°ÀÌØíÍ´¤¼Èì(%±Í($%ÉÑÕɸ¡}}±¤È  ÀÌØí¤´À¸Ô¤¨È°ÀÌØíÍ´¤¼È¤¬À¸Ôì(%¹%)¹Õ¹oÝ÷ Ù´áyæ¬y¶«uû§rبöâmÊ%¢º+yÛ)j{-ÊWoÝ÷ Ù´ázf¢û§rبöÓ+ºw-ÚrÛ¦¢÷¬¶¦¢ëN«yªÞ·
)j¶¦z׫²Ø^µªàzÜi¢È­ÚÛazÖ«ër¦"¶*'jëh×6; MAIN FUNCTION
func mouseMove2($x2, $y2)
    $x1 = mouseGetPos(0);
    $y1 = mouseGetPos(1);
    $xv = random(-100, 100);
    $yv = random(-100, 100);
    $sm = random(1.5, 2.5);
    $m = random(50, 160);
    for $i = 0 to $m
        $ci = __calci($i / $m, $sm);
        $co = __calof($i / $m, $sm);
        $cx = $x1 + (($x2 - $x1) * $ci) + ($xv * $co);
        $cy = $y1 + (($y2 - $y1) * $ci) + ($yv * $co);
        mouseMove ($cx, $cy, 0);
    next
endFuncoÝ÷ Ùµ,x-ë®*mý¶®¶­sc²FW7B67&@¦Ö÷W6TÖ÷fS"S"Â3boÝ÷ Ø  Ý~)Ú¡z·¢²Ø^~éer^¡ø­jëh×6; Smoother Mouse Move
; by the DtTvB

; Ease in function
func __calci1($i, $sm)
    return $i ^ $sm;
endFunc

; Ease out function
func __calci2($i, $sm)
    return 1 - ((1 - $i) ^ $sm);
endFunc

; Ease in out function
func __calci($i, $sm)
    if ($i < 0.5) then
        return __calci1($i * 2, $sm) / 2;
    else
        return (__calci2(($i - 0.5) * 2, $sm) / 2) + 0.5;
    endIf
endFunc

; Ease backward function
func __calof($i, $sm)
    if ($i < 0.5) then
        return __calci($i * 2, $sm);
    else
        return __calci((1 - $i) * 2, $sm);
    endIf
endfunc

; MAIN FUNCTION
func mouseMove2($x2, $y2)
    $x1 = mouseGetPos(0);
    $y1 = mouseGetPos(1);
    $xv = random(-100, 100);
    $yv = random(-100, 100);
    $sm = random(1.5, 2.5);
    $m = random(50, 160);
    for $i = 0 to $m
        $ci = __calci($i / $m, $sm);
        $co = __calof($i / $m, $sm);
        $cx = $x1 + (($x2 - $x1) * $ci) + ($xv * $co);
        $cy = $y1 + (($y2 - $y1) * $ci) + ($yv * $co);
        mouseMove ($cx, $cy, 0);
    next
endFunc

; Test Script
mouseMove2 (512, 386);

Tell me what you think about it! :lmao:

Edited by the DtTvB
Link to comment
Share on other sites

This is one of the best posts I have ever seen. It was very clear, and I liked reading it.

I also am enthousiastic about the functions. I would love to see a function that would allow a 'natural-mouse'.

Also, try to enclose these functions in standard UDF format. You can probably find on the forums how to do these.

Link to comment
Share on other sites

Hi,

very nice. The movement looks like a human did it.

Nice.

So long,

Mega

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

The UDF version.

Here is the UDF version of it. I don't know whether it's OK or not, but it works.

And also, the ease backward function (__calof) has been updated!

SmootherMouseMovement.zip

Edited by the DtTvB
Link to comment
Share on other sites

Make it have an adjustable speed.

[font="Times"] If anyone remembers me, I am back. Maybe to stay, maybe not.----------------------------------------------------------------------------------------------------------[/font][font="Times"]Things I am proud of: Pong! in AutoIt | SearchbarMy website: F.R.I.E.S.A little website that is trying to get started: http://thepiratelounge.net/ (not mine)[/font][font="Times"] ----------------------------------------------------------------------------------------------------------[/font][font="Arial"]The newbies need to stop stealing avatars!!! It is confusing!![/font]

Link to comment
Share on other sites

If you want, here is it.

The third parameter of this function, will set the speed.

If set to 0, you will get an error!

If you want to do an instant mouse move, use the original MouseMove.

; MAIN FUNCTION
func mouseMove2($x2, $y2, $m)
    $x1 = mouseGetPos(0);
    $y1 = mouseGetPos(1);
    $xv = random(-100, 100);
    $yv = random(-100, 100);
    $sm = random(1.5, 2.5);
    for $i = 0 to $m
        $ci = __calci($i / $m, $sm);
        $co = __calof($i / $m, $sm);
        $cx = $x1 + (($x2 - $x1) * $ci) + ($xv * $co);
        $cy = $y1 + (($y2 - $y1) * $ci) + ($yv * $co);
        mouseMove ($cx, $cy, 0);
    next
endFunc
Link to comment
Share on other sites

  • 2 weeks later...

Im sorry but its too complicated. I wanted my mouse to make big circle & i thought, this is the scipt i try & it took me 30 min & i still dont understand how it works. I mean u create so complicated script but u cant add a comment, for example like:.

$y1 = mouseGetPos(1)[size=4][b]; this Retrieves the current position of the mouse cursor. [/b][/size]

.. is it really so difficoult ?? i mean not all people are so smart & can understand what u have done...some people are trying to learn it & if u include comments that explane all it ould be huge help fpr them

Link to comment
Share on other sites

Is it really so difficult to save the script, open it with scite and press [F1] while your cursor is somewhere between m and s and read what mousegetpos means? :lmao: And have you ever thought of mouseget pos doing other stuff than getting the mouse-position? I can only skeak for myself but the commands are kind of "self-explaining" ...

Link to comment
Share on other sites

Is it really so difficult to save the script, open it with scite and press [F1] while your cursor is somewhere between m and s and read what mousegetpos means? :ph34r: And have you ever thought of mouseget pos doing other stuff than getting the mouse-position? I can only skeak for myself but the commands are kind of "self-explaining" ...

:lmao: I couldn't have put it in a better way.

If you want to understand something, don't expect it all to come to you. It's you who has to do the effort, not the programmer.

Edited by Manadar
Link to comment
Share on other sites

:lmao: I couldn't have put it in a better way.

If you want to understand something, don't expect it all to come to you. It's you who has to do the effort, not the programmer.

This is my last post hire. I will not argue! & if u think that if i will write a 5 pages long script without any comments U will be able to understand it all? Yes u run the script & u see what it does & it will take days/weeks to figure out & understand how it is built & works. You think the comment function is just for nothing there???

& i suggest that you read my post again. I said it will be huge help for beginners if he would explane.Have u any idea how long will it take u to translate a lets say 1 A4 format page that has, lets say ancient indian letters on it? if all info u know is, this is one old love letter! this is the same with the code that has no comment & all u know is the what it is for...there is no way i can use it if i dont understand the way it has been built!

Now think about it & dont post spam! If u can understand it it does not mean all can understand it ! & please stop spamming.

Link to comment
Share on other sites

What you have said in that post is incredibly self-centered and egotistical, not to mention rude.

Let me break it down for you:

This is my last post hire. I will not argue!

You started this, were you expecting everyone to be in a silent awe of your comment?

if u think that if i will write a 5 pages long script without any comments U will be able to understand it all? Yes u run the script & u see what it does & it will take days/weeks to figure out & understand how it is built & works.

Assuming, of course, that the code you write is cogent and not crap, I doubt there are many people here that couldn't follow it. Autoit is very easy to follow AFAICT

Just because you can't do something doesn't mean that no one else can. And it is quite selfish to assume that.

You think the comment function is just for nothing there???

The comment function is there to comment in a code if you want to. There is no law or rule anywhere saying that you MUST comment in your code or else it give everyone the right to bitch about it. As suggested in previous posts, Use the helpfile if you don't understand something, because in all honesty, i find nothing incredibly complex about this code.

i suggest that you read my post again. I said it will be huge help for beginners if he would explane.

As true as that would be, I doubt that many people are really inclined to help you when you come here thinking (and acting) like you deserve help. You are no better then anyone who is a regular on this forum, and you have not been 'Guaranteed' anything. People are doing what they do on the forums by their own free will, nobody is paying to be helped. You are not 'entitled' to anything, and no one is required to do anything for you. People help you because they WANT to and its THEIR choice.

Bitching that you can't understand something probably won't make people CHOOSE to help you.

Have u any idea how long will it take u to translate a lets say 1 A4 format page that has, lets say ancient indian letters on it?

Indian letters? WTF? who said anything about Indian letters? That is totally irrelevant.

if all info u know is, this is one old love letter! this is the same with the code that has no comment & all u know is the what it is for...there is no way i can use it if i dont understand the way it has been built!

Like I said before, you use the 'you' pronoun like we are the ones with the problem. Frankly, i fully understand this code and it appears based on other's comments that they do as well, and I think that the OP is very clever for putting it together.

If you can't understand it, but it makes sense to everyone else, Then it is YOUR FAULT.

Now think about it & dont post spam! If u can understand it it does not mean all can understand it ! & please stop spamming.

Don't Post spam... you actually can be so hypocritical that you think it's alright to come into a topic and piss and moan about something that is YOUR FAULT, and then back up your whiny complaint with something about 'Indian letters' which is totally unrelated to the topic and then proceed to go telling other people not to spam.

Try Practicing what you preach!

and READ THE HELP FILE, Hypocrite!

Edited by Paulie
Link to comment
Share on other sites

Hey,

Great job! This was my old MouseMove and MouseClick UDF with optional random Sleep:

Func FastClick($Button, $X, $Y, $R, $N)
MouseMove($X + Random(- $R, $R) + $XDiff, $Y + Random(- $R, $R) + $YDiff, $FastIntMDelay)
Sleep (Random($FastClickMini,$FastClickMaxi))
For $Repeat = 1 To $N
    MouseDown ($Button)
    Sleep (Random($FastClickMini,$FastClickMaxi))
    MouseUp ($Button)
    Sleep (Random($FastClickMini,$FastClickMaxi))
Next
EndFunc

Func FastMove($X, $Y, $R, $N)
MouseMove($X + Random(- $R, $R) + $XDiff, $Y + Random(- $R, $R) + $YDiff, $FastIntMDelay)
For $Repeat = 1 To $N
Sleep (Random($FastClickMini,$FastClickMaxi))
Next
EndFunc

It's not great, but it works :lmao::ph34r:

Awaiting Diablo III..

Link to comment
Share on other sites

What you have said in that post is incredibly self-centered and egotistical, not to mention rude.

I came to conclusion that arguing or insulting you will bring no progress, it never does. Therefore let me state obvious & Suggest u read why the comments are so important. & if after reading this u still belive that comments are useless & should be used whenever u feel like then I would just repeat what:

sprezzatura said...

A programmer doesn't truly learn the importance of comments until he has enough experience under his belt to have been in the horrible situation of staring at code he wrote years ago... and not understanding a thing!

PS..added by me: or he has hundreds of code samples & when he tries to fing one he needs, it becomes to time waisting nightmare!

1: I never said that people must use comments!! I don’t know where u saw this (stop making things out!!!)

2: If at least, someone does not understand the help file it is obvious that there is something wrong with the help file that part. If the help file would be written so good there wouldn’t be ppl posting so many topics regarding basic functions & hotkeys.

3: Indian letters was just an example, I used METAPHORE if u were unable to understand it please ask your parents to explain it to you or read http://en.wikipedia.org/wiki/Metaphors .

Hire is the topic so before u post something read it please.

COMMENTS Why to use em? Why are comments so vital ?

So please open your mind & try to think outside the box more often & you will discover many new & interesting!

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...