'引用随机函数,让鼠标在屏幕中抖动,可按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
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)