devxlogo

Make Your Mouse Pointer Tremble

Make Your Mouse Pointer Tremble

To make your mouse pointer appear to be trembling, you first create a form with ScaleMode = 3 – Pixel. Then use the following code:

Option ExplicitPrivate Type POINTAPI    X As Long    Y As LongEnd Type'Windows API functions to set the cursor positionPrivate Declare Function SetCursorPos Lib "User32" (ByVal X As Long,_    ByVal Y As Long) As Long    Private Declare Function ClientToScreen Lib "User32" (ByVal hWnd As_ Long, lpPoint As POINTAPI) As LongDim lpPoint As POINTAPI'To get the mouse position at every momentPrivate Sub Form_MouseMove(Button As Integer, Shift As Integer,_X As Single, Y As Single)    lpPoint.X = X    lpPoint.Y = Y   End SubPrivate Sub Timer_Timer()    If lpPoint.X < Form1.ScaleWidth And lpPoint.Y < Form1.ScaleHeight Then        lpPoint.X = lpPoint.X + Rand(-3, 3)        lpPoint.Y = lpPoint.Y + Rand(-3, 3)        ClientToScreen hWnd, lpPoint        SetCursorPos lpPoint.X, lpPoint.Y    End IfEnd Sub'To create the random valueFunction Rand(ByVal Low As Integer, ByVal High As Integer) As Integer Rand = ((High - Low) * Rnd) + LowEnd Function
See also  Why ChatGPT Is So Important Today
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist