vb 鼠标不停地抖动 要怎么写?

vb 鼠标不停地抖动 要怎么写?,第1张

一楼的方枯昌模法是很有用的哦,借鉴一下,可以完成你要鼠标上下左右不停抖动的感觉,没缓只需要引用随机函数就行了

'引用随机函数,让鼠标在屏幕中抖动,可按Ctrl+Break暂停,或按Alt+F4结束

Private Declare Function SetCursorPos&Lib "user32" (ByVal x As Long, ByVal y As Long)

Private Declare Function GetCursorPos&Lib "user32" (XY As PointAPI)

Private Type PointAPI

x As Long: y As Long

End Type

Private Sub Form_Load()

Timer1.Enabled = True

Timer1.Interval = 10 '抖动频率

End Sub

Private Sub Timer1_Timer()

Dim XY As PointAPI, foot As Integer

Call GetCursorPos(XY)

Randomize

foot = 5 '抖动幅度

XY.x = XY.x + 5 * (-1) ^ Int(1 + 2 * Rnd) '-1的迅巧乘方,左右抖动

XY.y = XY.y + 5 * (-1) ^ Int(1 + 2 * Rnd) '-1的乘方,上下抖动

SetCursorPos XY.x, XY.y

End Sub

VB 通过 SystemParametersInfo SPI_SETMOUSE 调节指蠢枣鼠标灵敏度

Global Const SPI_GETMOUSE = 3

Global Const SPI_SETMOUSE = 4

Global Const SPIF_SENDWININICHANGE = &H2

Declare Function SystemParametersInfo&Lib "user32" Alias "SystemParametersInfoA"唯拆 (ByVal uAction As Long, ByVal uParam As Long, lpvParam As Any, ByVal fuWinIni As Long)

Declare Function SystemParametersInfoByVal&Lib "user32" Alias "SystemParametersInfoA" (ByVal uAction As Long, ByVal uParam As Long, ByVal lpvParam As Any, ByVal fuWinIni As Long)

Private Sub Command1_Click()

Dim fResult As Long

Dim aMouseInfo(0 To 2) As Long

fResult = SystemParametersInfo&(SPI_GETMOUSE, 0, aMouseInfo(0), 0)

If fResult <>档仔 0 Then

aMouseInfo(2) = aMouseInfo(2) * 2

SystemParametersInfo&SPI_SETMOUSE, 0, aMouseInfo(0), SPIF_SENDWININICHANGE

End If

End Sub


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/yw/12374696.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-25
下一篇 2023-05-25

发表评论

登录后才能评论

评论列表(0条)

保存