vb下如何实现鼠标连发?

要代码,好的可以加分
2楼想要专业语言是不是,利用全局HOOK捕获鼠标按下事件,然后模拟点击鼠标键100次,S b不会就不要 bi,回乡下耕田去

Option Explicit On
Public Class Form1
Dim x As Long, y As Long
Dim yn As Double
Dim i As Integer

Private Declare Function SetCursorPos& Lib "user32" (ByVal x As Long, ByVal y As Long)
Private Declare Sub mouse_event Lib "user32" (ByVal dwFlags As Long, ByVal dx As Long, _
ByVal dy As Long, ByVal cButtons As Long, ByVal dwExtraInfo As Long)

Private Const MOUSEEVENTF_LEFTDOWN = &H2
Private Const MOUSEEVENTF_LEFTUP = &H4

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
'x = System.Windows.Forms.Cursor.Position.X
'y = System.Windows.Forms.Cursor.Position.Y
i = i + 1
If i > 100 Then Timer1.Enabled = False
x = Form1.MousePosition.X
y = Form1.MousePosition.Y
TextBox1.Text = x
TextBox2.Text = y
SetCursorPos(x, y)
If yn = True Then
Form1.mouse_event(MOUSEEVENTF_LEFTDOWN, x, y, 0, 0)
'mouse_event(MOUSEEVENTF_LEFTDOWN, x, y, 0, 0) '鼠标左键按下
yn = False
Else : yn = True
Form1.mouse_event(MOUSEEVENTF_LEFTUP, x, y, 0, 0) '鼠标左键抬起
End If
End Sub

Private Sub Form1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseDown
Timer1.Enabled = True
End Sub

End Class
......................
鼠标按下后,连击100次。
温馨提示:内容为网友见解,仅供参考
第1个回答  2009-12-21
是按键精灵吗
如果是
声名:
Private Declare Sub mouse_event Lib "user32" _
(ByVal dwFlags As Long, ByVal dx As Long, _
ByVal dy As Long, ByVal cButtons As Long, _
ByVal dwExtraInfo As Long)
Const MOUSEEVENTF_LEFTDOWN = &H2
Const MOUSEEVENTF_LEFTUP = &H4
Const MOUSEEVENTF_MIDDLEDOWN = &H20
Const MOUSEEVENTF_MIDDLEUP = &H40
Const MOUSEEVENTF_MOVE = &H1
Const MOUSEEVENTF_ABSOLUTE = &H8000
Const MOUSEEVENTF_RIGHTDOWN = &H8
Const MOUSEEVENTF_RIGHTUP = &H10
用法:
mouse_event MOUSEEVENTF_LEFTDOWN Or MOUSEEVENTF_LEFTUP, 0, 0, 0, 0
这个就是按键
第2个回答  2009-12-23
我在想什么叫鼠标连发.学了这么长时间,还真不知什么叫连发.难道是连续多次发送某一鼠标事件?

VB 怎样实现鼠标连点
可以使用API函数mouse_event实现鼠标动作,包括单击,移动等。如:Option Explicit Private Declare Sub mouse_event Lib "user32 " (ByVal dwFlags As Long, ByVal dx As Long, ByVal dy As Long, ByVal cButtons As Long, ByVal dwExtraInfo As Long)Const MOUSEEVENTF_LEFTDOWN = &H2 Const ...

VB怎么实现鼠标移动过去执行一个命令按下去又执行另一命令?
Private Sub Text1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)Debug.Print "这是鼠标按下去执行的命令"End Sub Private Sub Text1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)Debug.Print "这是鼠标移动过去执行的命令。注意,...

vb下如何实现鼠标连发?
鼠标按下后,连击100次。

如何用VB做鼠标连续点击左键
Public Declare Sub mouse_event Lib "user32" (ByVal dwFlags As Long, ByVal dx As Long, ByVal dy As Long, ByVal cButtons As Long, ByVal dwExtraInfo As Long) '定义鼠标事件 Public Const MOUSEEVENTF_LEFTDOWN = &H2 ' left button down Public Const MOUSEEVENTF_LEFTUP = &H4...

在VB的环境中如何让鼠标右键自动连击
现在言归正传,VB模拟鼠标事件需要用到API来实现,具体如下:'以下代码放在窗体模块中,如果要放在代码模块中请将Private改为Public Private Declare Sub mouse_event Lib "user32" (ByVal dwFlags As Long, ByVal dx As Long, ByVal dy As Long, ByVal cButtons As Long, ByVal dwExtraInfo As...

vb 用快捷键怎么实现 鼠标左键连点?
这个问题建议你下载以个按键精灵或者按键游戏啊,什么程序都不需要写,直接定义一个激活键,也就是你的(~),然后定义左键点击就可以了。完全不需要写程序。里面涉及到的语言是VBS,只要有点VB基础就看得懂。

如何使vb的窗体在电脑屏幕上随鼠标一起移动?
先用VB做一个窗口,在top0 left0 的位置。使鼠标一移动到窗口,窗口就跑到屏幕右上角再移动到屏幕右上角,就跑到右下角,接着在屏幕右下角的窗口里移动又跑到左下角,最后在屏幕左下角的窗口里移动又跑回原来的位置。就这样不断循环。这是我跟网上学,写的代码,但是移到右上角的时候就不动了...

VB里的mousemove事件举例
vb Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)' 在此处编写处理鼠标移动事件的代码 ' Button参数表示按下的鼠标按钮(如果有)' Shift参数表示是否同时按下了Shift、Ctrl或Alt键 ' X和Y参数表示鼠标指针在窗体上的位置 ' 例如,可以在窗体上显示...

[vb]按住SHIFT,用鼠标点击一下屏幕上的任何一个地方,鼠标就会自动连续点 ...
MsgBox ""End SubPrivate Sub Form_Load()Timer1.Interval = 50 Timer1.Enabled = True End SubPrivate Sub Timer1_Timer()Dim a As Long a = 0 If GetAsyncKeyState(vbKeyShift) Then MsgBox "请把鼠标移到你想连点10下的地方按ENTER"Do mouse_event MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0: ...

VB怎么实现连续按鼠标左键呢 还就是在任何窗口都可以实现
mouse_event 函数可以实现,这是一个API函数,声明后即可使用

相似回答
大家正在搜