求助:用VB编写的监控小工具代码
发布网友
发布时间:2022-08-31 07:40
我来回答
共5个回答
热心网友
时间:2024-12-09 20:39
说我的那个 不明白就回家学习去!
这个就是代码 也不知道你要做什么
我模拟鼠标用的mouse_event
如果你要用在游戏上 游戏本身可能会屏蔽
所以可能会没反应
启动程序用shell "c:\1.exe" 就行
在窗体调用enablehook
以下代码要放在模块中!
Declare Function SetWindowsHookEx Lib "user32" Alias _
"SetWindowsHookExA" (ByVal idHook As Long, ByVal lpfn As Long, _
ByVal hmod As Long, ByVal dwThreadId As Long) As Long
Declare Function UnhookWindowsHookEx Lib "user32" _
(ByVal hHook As Long) As Long
Declare Function CallNextHookEx Lib "user32" (ByVal hHook As Long, _
ByVal nCode As Long, ByVal wParam As Long, lParam As Any) As Long
Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" _
(lpvDest As Any, ByVal lpvSource As Long, ByVal cbCopy As Long)
Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, _
ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, _
ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Declare Function SetCursorPos Lib "user32" (ByVal x As Long, ByVal y As Long) As Long
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
Public Const MOUSEEVENTF_LEFTUP = &H4
Public Const WH_MOUSE = 7
Public Const WM_RBUTTONDOWN = &H204
Public Const HC_ACTION = 0
Public Const WM_RBUTTONUP = &H205
Public Const WM_LBUTTONDOWN = &H201
Public Const WM_LBUTTONUP = &H202
Public hHook As Long
Sub EnableHook()
If hHook = 0 Then
hHook = SetWindowsHookEx(WH_MOUSE, AddressOf MouseHookProc, App.hInstance, &O0)
End If
End Sub
Sub DelHook()
Dim ret As Long
If hHook <> 0 Then
ret = UnhookWindowsHookEx(hHook)
hHook = 0
End If
End Sub
Function MouseHookProc(ByVal code As Long, ByVal wParam As Long, _
ByVal lParam As Long) As Long
Dim MouseDown As Boolean
MouseDown = False
If code < 0 Then
MouseHookProc = CallNextHookEx(hHook, code, ByVal wParam, ByVal lParam)
Exit Function
End If
If wParam = WM_RBUTTONDOWN Or wParam = WM_RBUTTONUP Then
MouseDown = True
End If
If MouseDown = True Then
MouseHookProc = 1
SetCursorPos 100, 100 '移动指针
Sleep 1000 '暂停毫秒
mouse_event MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0 '左键按下
mouse_event MOUSEEVENTF_LEFTUP, 0, 0, 0, 0 '左键弹起
Call DelHook()
Else
Call CallNextHookEx(hHook, code, ByVal wParam, ByVal lParam)
End If
End Function
真搞笑 在这个板块论了这么久第一次有人这么说我
有人说我不会 哈哈
你要是不明白我说的是什么意思就别在这乱说了
连用API都不明白 回家呆着吧
如果是在游戏中 还是用按键精灵吧 那样方便
比编VB方便很多
运行后 shell 一个程序
用全局hook 监视鼠标单击
发现单击
setcursorpos 到指定点
postmessage 左键单击 或其他按键
退出
热心网友
时间:2024-12-09 20:40
如果是搜索软件,请到搜索引擎或其他软件下载网站
要学习代码太早点,先把基础的东西不说搞的起码搞得差不多了,再去玩这些高深的东西吧
热心网友
时间:2024-12-09 20:40
你们都是文化人,何必打架!
热心网友
时间:2024-12-09 20:41
貌似打起来了
热心网友
时间:2024-12-09 20:41
不是貌似
是真的