VB Random Mobile Mouse

Source: Internet
Author: User

Create a new project, put a button command1, put a clock timer1, copy the following code to run, press the button will find the mouse randomly move, hit the border will bounce, and then press the button (or enter) will stop.
' ***************************** Copy the following code *****************************************

PrivateType Pointapi x as Longy as LongEndTypePrivate Declare FunctionGetCursorPosLib "User32"(Lppoint asPOINTAPI) as LongPrivate Declare FunctionSetcursorposLib "User32"(ByValX as Long,ByValY as Long) as LongDimRndx as Integer, Rndy as Integer  'define the random direction and rate of movementPrivate SubCommand1_Click ()IfRndx <>0  andRndy <>0  ThenRndx=0Rndy=0    Exit Sub  End If   whileRndx =0Rndx=Rnd* --TenWend whileRndy =0Rndy=Rnd* --TenWendEnd SubPrivate SubForm_Load () timer1.interval=TenEnd SubPrivate SubTimer1_timer ()DimPos asPOINTAPI, X as LongY as Long  IfRndx =0  andRndy =0  Then    Rnd    Exit Sub  End Ifgetcursorpos POS x= Pos.x +Rndx y= Pos.y +RndyIfX < -  Thenx= -Rndx= Rndx * (-1)  End If  IfX >= screen.width/ the- -  Thenx= Screen.width/ the- -Rndx= Rndx * (-1)  End If  IfY < -  Theny= -Rndy= Rndy * (-1)  End If  IfY >= screen.height/ the- -  Theny= Screen.height/ the- -Rndy= Rndy * (-1)  End Ifsetcursorpos x, yEnd Sub

Transferred from: http://bbs.bccn.net/thread-407793-1-1.html

VB Random Mobile Mouse

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.