vb 我做的postmessage发送消息的小程序 为什么只能在窗口最小化时才有用? 纠结 早点给答案 再加100分
DimlpClassNameAsString,lpWindowNameAsStringlpClassName="类名"lpWindowName="标题名"'类名和标题都是...
Dim lpClassName As String, lpWindowName As String
lpClassName = "类名"
lpWindowName = "标题名"'类名和标题都是用spy++找的
hwnd1 = FindWindow(lpClassName, lpWindowName)
hwnd2 = hwnd1
If hwnd2 <> 0 Then
'MsgBox "句柄2是" & hwnd2
Dim wMsg As Long, wParam As Long, lParam As Long, Rx As Long, xx As Integer, yy As Integer
xx = 800 '点击的x坐标
yy = 600 '点击的y坐标
wMsg = WM_LBUTTONDOWN '左键按下消息
wParam = 1
lParam = yy * 65536 + xx
Sleep 500
Call PostMessage(hwnd2, wMsg, wParam, lParam) '发送消息
Sleep 300
wMsg = WM_LBUTTONUP '左键抬起消息
wParam = 1
lParam = yy * 65536 + xx
Call PostMessage(hwnd2, wMsg, wParam, lParam) '发送消息
Else
MsgBox "句柄2为0"
End If
窗口最小化时有用的 打开就没用了
sendmessage 刚试过 跟postmessage 一样 不过 sendmessage 我用的不熟练 点击的坐标很BT 我都不知道 点到哪里去了(目标程序是个3D游戏) sendmessage 用的话人物一直往地图边缘跑 一直跑到不能跑 牛B 用postmessage 绝对跑不跑了那么远 可窗口打开的话跟postmessage一样 还是无效 我开了2个窗口 展开
lpClassName = "类名"
lpWindowName = "标题名"'类名和标题都是用spy++找的
hwnd1 = FindWindow(lpClassName, lpWindowName)
hwnd2 = hwnd1
If hwnd2 <> 0 Then
'MsgBox "句柄2是" & hwnd2
Dim wMsg As Long, wParam As Long, lParam As Long, Rx As Long, xx As Integer, yy As Integer
xx = 800 '点击的x坐标
yy = 600 '点击的y坐标
wMsg = WM_LBUTTONDOWN '左键按下消息
wParam = 1
lParam = yy * 65536 + xx
Sleep 500
Call PostMessage(hwnd2, wMsg, wParam, lParam) '发送消息
Sleep 300
wMsg = WM_LBUTTONUP '左键抬起消息
wParam = 1
lParam = yy * 65536 + xx
Call PostMessage(hwnd2, wMsg, wParam, lParam) '发送消息
Else
MsgBox "句柄2为0"
End If
窗口最小化时有用的 打开就没用了
sendmessage 刚试过 跟postmessage 一样 不过 sendmessage 我用的不熟练 点击的坐标很BT 我都不知道 点到哪里去了(目标程序是个3D游戏) sendmessage 用的话人物一直往地图边缘跑 一直跑到不能跑 牛B 用postmessage 绝对跑不跑了那么远 可窗口打开的话跟postmessage一样 还是无效 我开了2个窗口 展开
3个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询