VB快捷键点鼠标左键代码

问下如何用VB用快捷键连点鼠标左键,说清楚用什么控件,按下Ctrl+F1启动,Ctrl+F2关闭... 问下如何用VB用快捷键连点鼠标左键,说清楚用什么控件,
按下Ctrl+F1启动 ,Ctrl+F2关闭
展开
 我来答
lidajiangzw
2011-03-06 · TA获得超过903个赞
知道小有建树答主
回答量:774
采纳率:0%
帮助的人:718万
展开全部
分都没的
只告诉你用到的API 自己下去看
mouse_event
SetWindowHookEx
UnhookWindowsHookEx
Sleep
Getasynckeystate
追问
给你20分吧,快把代码说出来
追答
前段没时间

'form代码

Private Sub Form_Load()
RegisterHotKey Me.hWnd, 1, 2, vbKeyF1
RegisterHotKey Me.hWnd, 2, 2, vbKeyF2
RegisterHotKey Me.hWnd, 3, 2, vbKeyF3
owndprc = SetWindowLong(Me.hWnd, -4, AddressOf hotkey)
whide = 1
wsig1 = 0
End Sub

Private Sub Form_Unload(Cancel As Integer)
mclk = 0
UnregisterHotKey Me.hWnd, 1
UnregisterHotKey Me.hWnd, 2
UnregisterHotKey Me.hWnd, 3
End Sub

标准模块

Public Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Public Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hWnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Public Declare Function RegisterHotKey Lib "user32" (ByVal hWnd As Long, ByVal ID As Long, ByVal fsModifiers As Long, ByVal vk As Long) As Long
Public Declare Function UnregisterHotKey Lib "user32" (ByVal hWnd As Long, ByVal ID As Long) As Long
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 Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Public owndprc As Long
Public whide As Integer, mclk As Integer, wsig1 As Integer

Public Function hotkey(ByVal hWnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
If Msg = &H312 Then
Select Case wParam
Case 1
If wsig1 = 0 Then Call wnd1
Case 2
mclk = 0
Case 3
Call wnd3
End Select
End If
hotkey = CallWindowProc(owndprc, hWnd, Msg, wParam, lParam)
End Function

Sub wnd1()
mclk = 1
wsig1 = 1
Do
DoEvents
mouse_event &H2, 0, 0, 0, 0
Sleep 50
mouse_event &H4, 0, 0, 0, 0
Sleep 200
If mclk = 0 Then wsig1 = 0: Exit Sub
Loop
End Sub

Sub wnd3()
If whide = 1 Then
Form1.Hide
whide = 0
Else
Form1.Show
whide = 1
End If
End Sub
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式