VB快捷键点鼠标左键代码
问下如何用VB用快捷键连点鼠标左键,说清楚用什么控件,按下Ctrl+F1启动,Ctrl+F2关闭...
问下如何用VB用快捷键连点鼠标左键,说清楚用什么控件,
按下Ctrl+F1启动 ,Ctrl+F2关闭 展开
按下Ctrl+F1启动 ,Ctrl+F2关闭 展开
1个回答
展开全部
分都没的
只告诉你用到的API 自己下去看
mouse_event
SetWindowHookEx
UnhookWindowsHookEx
Sleep
Getasynckeystate
只告诉你用到的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
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询