CoolRandom Mouse Mover

Posts 1–4 of 4 · Page 1 of 1
Random Mouse Mover
I just wanted to release this because it can be funny if applied right to screw with people. Basically what this code does is makes the mouse move randomly accross the screen Enjoy and don't forget to thanks for another release thanks

Code:
        
        Dim screenWidth As Integer = Screen.PrimaryScreen.Bounds.Width
        Dim screenHeight As Integer = Screen.PrimaryScreen.Bounds.Height

        While True
            Dim randomxValue As Integer
            Dim randomyValue As Integer
            randomxValue = CInt(Math.Floor((screenWidth - 0 + 1) * Rnd())) + 0
            randomyValue = CInt(Math.Floor((screenHeight - 0 + 1) * Rnd())) + 0
            Cursor.Position = (New Point(randomxValue, randomyValue))
        End While
If you are doing a vb project or something and need help don't hesitate to contact me on skype: Gamerion24
First you could improve your data types. It will not affect performance but to improve your coding you should do it.
You don't need integer values at this point.
Dim as uInt16 is way more than enough.
Code:
Dim screenWidth As uInt16 = Screen.PrimaryScreen.Bounds.Width
Dim screenHeight As uInt16 = Screen.PrimaryScreen.Bounds.Height
Why do you substract 0 and than add 1 and after all again adding 0?
Furthermore you don't need to convert a decimal output to integer in vb.net.
Code:
randomxValue = CInt(Math.Floor((screenWidth - 0 + 1) * Rnd())) + 0
randomyValue = CInt(Math.Floor((screenHeight - 0 + 1) * Rnd())) + 0
You could improve performance if you won't declare the x & y variables in each loop.
Furthermore you should pause the loop after you set the cursor position, you don't need to repeat it as fast as possible.


Some tipps for you to improve your coding, should not be interpreted as flame or superior attitude.
Quote Originally Posted by RoPMadM View Post
First you could improve your data types. It will not affect performance but to improve your coding you should do it.
You don't need integer values at this point.
Dim as uInt16 is way more than enough.
Code:
Dim screenWidth As uInt16 = Screen.PrimaryScreen.Bounds.Width
Dim screenHeight As uInt16 = Screen.PrimaryScreen.Bounds.Height
Why do you substract 0 and than add 1 and after all again adding 0?
Furthermore you don't need to convert a decimal output to integer in vb.net.
Code:
randomxValue = CInt(Math.Floor((screenWidth - 0 + 1) * Rnd())) + 0
randomyValue = CInt(Math.Floor((screenHeight - 0 + 1) * Rnd())) + 0
You could improve performance if you won't declare the x & y variables in each loop.
Furthermore you should pause the loop after you set the cursor position, you don't need to repeat it as fast as possible.


Some tipps for you to improve your coding, should not be interpreted as flame or superior attitude.
ye you got some valid points here haha :P
Quote Originally Posted by Gamerion View Post
ye you got some valid points here haha :P
So do you apply those tipps?
If yes please update your thread
Posts 1–4 of 4 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

Talk with us