VB获取游戏窗口句柄
我用VB做一个问道的喊话器想做后台的,所以需要获取游戏窗口句柄谁能帮下,,顺便帮我翻译下这段代码,,方便我学习,,谢谢了,PrivateSubTimer1_Timer()...
我用VB做一个问道的喊话器 想做后台的,所以需要获取游戏窗口句柄
谁能帮下,,顺便帮我翻译下这段代码,,方便我学习,,谢谢了,
Private Sub Timer1_Timer()
Dim str As String, data() As Byte, i As Integer
Dim Mir2Hwnd As Long, hwnd As Long
Mir2Hwnd = FindWindow("TFrmMain", "legend of mir2")
hwnd = FindWindowEx(Mir2Hwnd, 0, "TDXDraw", vbNullString)
PostMessage hwnd, WM_SETFOCUS, 0, 0 '获得窗口焦点
PostMessage hwnd, WM_KEYDOWN, 0, 0 '发送回车键
'PostMessage hwnd, WM_KEYDOWN, VK_UP, MapVirtualKey(VK_UP, WM_KEYDOWN) '发送向上键
'PostMessage hwnd, WM_KEYDOWN, VK_RETURN, MapVirtualKey(VK_RETURN, WM_KEYDOWN) '发送回车键
str = Text1.Text 'Str为喊话内容
i = 0
data = StrConv(str, vbFromUnicode)
While i <= UBound(data)
If data(i) < 128 Then
PostMessage hwnd, WM_CHAR, data(i), 0&
PostMessage hwnd, WM_SETFOCUS, 0, 0 '获得窗口焦点
PostMessage hwnd, WM_KEYDOWN, VK_RETURN, MapVirtualKey(VK_RETURN, WM_KEYDOWN) '发送回车键
i = i + 1
Else
PostMessage hwnd, WM_CHAR, data(i), 0&
PostMessage hwnd, WM_CHAR, data(i + 1), 0&
i = i + 2
End If
Wend
End Sub
这段代码我看不明白,希望会的可以教教.谢谢了 展开
谁能帮下,,顺便帮我翻译下这段代码,,方便我学习,,谢谢了,
Private Sub Timer1_Timer()
Dim str As String, data() As Byte, i As Integer
Dim Mir2Hwnd As Long, hwnd As Long
Mir2Hwnd = FindWindow("TFrmMain", "legend of mir2")
hwnd = FindWindowEx(Mir2Hwnd, 0, "TDXDraw", vbNullString)
PostMessage hwnd, WM_SETFOCUS, 0, 0 '获得窗口焦点
PostMessage hwnd, WM_KEYDOWN, 0, 0 '发送回车键
'PostMessage hwnd, WM_KEYDOWN, VK_UP, MapVirtualKey(VK_UP, WM_KEYDOWN) '发送向上键
'PostMessage hwnd, WM_KEYDOWN, VK_RETURN, MapVirtualKey(VK_RETURN, WM_KEYDOWN) '发送回车键
str = Text1.Text 'Str为喊话内容
i = 0
data = StrConv(str, vbFromUnicode)
While i <= UBound(data)
If data(i) < 128 Then
PostMessage hwnd, WM_CHAR, data(i), 0&
PostMessage hwnd, WM_SETFOCUS, 0, 0 '获得窗口焦点
PostMessage hwnd, WM_KEYDOWN, VK_RETURN, MapVirtualKey(VK_RETURN, WM_KEYDOWN) '发送回车键
i = i + 1
Else
PostMessage hwnd, WM_CHAR, data(i), 0&
PostMessage hwnd, WM_CHAR, data(i + 1), 0&
i = i + 2
End If
Wend
End Sub
这段代码我看不明白,希望会的可以教教.谢谢了 展开
展开全部
'下面取游戏窗口句柄 hwnd
Mir2Hwnd = FindWindow("TFrmMain", "legend of mir2")
hwnd = FindWindowEx(Mir2Hwnd, 0, "TDXDraw", vbNullString)
'以下为虚拟按键
PostMessage hwnd, WM_SETFOCUS, 0, 0 '获得窗口焦点
PostMessage hwnd, WM_KEYDOWN, 0, 0 '发送回车键
'PostMessage hwnd, WM_KEYDOWN, VK_UP, MapVirtualKey(VK_UP, WM_KEYDOWN) '发送向上键
'PostMessage hwnd, WM_KEYDOWN, VK_RETURN, MapVirtualKey(VK_RETURN, WM_KEYDOWN) '发送回车键
'向游戏窗口发送喊话内容
PostMessage hwnd, WM_CHAR, data(i), 0&
PostMessage hwnd, WM_CHAR, data(i + 1), 0&
___________
以上代码也可以用VBS实现, 且更简单. 如有不明,请qq 312897211
Mir2Hwnd = FindWindow("TFrmMain", "legend of mir2")
hwnd = FindWindowEx(Mir2Hwnd, 0, "TDXDraw", vbNullString)
'以下为虚拟按键
PostMessage hwnd, WM_SETFOCUS, 0, 0 '获得窗口焦点
PostMessage hwnd, WM_KEYDOWN, 0, 0 '发送回车键
'PostMessage hwnd, WM_KEYDOWN, VK_UP, MapVirtualKey(VK_UP, WM_KEYDOWN) '发送向上键
'PostMessage hwnd, WM_KEYDOWN, VK_RETURN, MapVirtualKey(VK_RETURN, WM_KEYDOWN) '发送回车键
'向游戏窗口发送喊话内容
PostMessage hwnd, WM_CHAR, data(i), 0&
PostMessage hwnd, WM_CHAR, data(i + 1), 0&
___________
以上代码也可以用VBS实现, 且更简单. 如有不明,请qq 312897211
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
VB获取游戏窗口句柄
Private Sub Form_Load()
Timer1.Enabled = True
Timer1.Interval = 1000
End Sub
Private Sub Timer1_Timer()
Dim cc As Long
cc = FindWindow(vbNullString, "计算器")
If cc = 0 Then
Label1.Caption = "程序未能连接成功"
Else
Label1.Caption = "连接成功"
End If
End Sub
Private Sub Form_Load()
Timer1.Enabled = True
Timer1.Interval = 1000
End Sub
Private Sub Timer1_Timer()
Dim cc As Long
cc = FindWindow(vbNullString, "计算器")
If cc = 0 Then
Label1.Caption = "程序未能连接成功"
Else
Label1.Caption = "连接成功"
End If
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询