主题:游戏窗口该怎么激活
我的代码,这是前面的声明
Private Declare Function GetFocus Lib "user32" () As Long
Private Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hwnd As Long, lpdwProcessId As Long) As Long
Private Declare Function AttachThreadInput Lib "user32" (ByVal idAttach As Long, ByVal idAttachTo As Long, ByVal fAttach As Long) As Long
Private Declare Function GetForegroundWindow Lib "user32" () As Long
Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Private Const WM_CHAR = &H102
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Private Declare Function GetCurrentThreadId Lib "kernel32" () As Long
Sub e()
sendkeys "y" '以CS为例,聊天需要先激活聊天对话框,这个键就是起激活对话框的作用。当然也可以是"~" 或者 " "
Dim hd As Long
Dim ttHD As Long
Dim msg As String
Dim i As Integer
Dim bytemsg() As Byte
msg = Text18.Text
hd = GetForegroundWindow()
ttHD = GetWindowThreadProcessId(hd, 0)
AttachThreadInput ttHD, App.ThreadID, True
hd = GetFocus
AttachThreadInput ttHD, App.ThreadID, False
bytemsg = StrConv(Text18.Text, vbFromUnicode)
For i = LBound(bytemsg) To UBound(bytemsg)
PostMessage hd, WM_CHAR, bytemsg(i), 0
Next i
sendkeys "~" '聊天之后需要回车发送聊天内容
End Sub
我试着排列sendkeys在块中的顺序,发现,无论放在什么地方,sendkeys总是发生在字符传送之后。
我也曾经把sendkeys单独写在另一个块中,但事件仍旧发生在发送字符之后。
求高手帮一下忙
这个sendkeys怎么才能发送在下面的命令之前?
有其他解决方法也行。
Private Declare Function GetFocus Lib "user32" () As Long
Private Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hwnd As Long, lpdwProcessId As Long) As Long
Private Declare Function AttachThreadInput Lib "user32" (ByVal idAttach As Long, ByVal idAttachTo As Long, ByVal fAttach As Long) As Long
Private Declare Function GetForegroundWindow Lib "user32" () As Long
Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Private Const WM_CHAR = &H102
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Private Declare Function GetCurrentThreadId Lib "kernel32" () As Long
Sub e()
sendkeys "y" '以CS为例,聊天需要先激活聊天对话框,这个键就是起激活对话框的作用。当然也可以是"~" 或者 " "
Dim hd As Long
Dim ttHD As Long
Dim msg As String
Dim i As Integer
Dim bytemsg() As Byte
msg = Text18.Text
hd = GetForegroundWindow()
ttHD = GetWindowThreadProcessId(hd, 0)
AttachThreadInput ttHD, App.ThreadID, True
hd = GetFocus
AttachThreadInput ttHD, App.ThreadID, False
bytemsg = StrConv(Text18.Text, vbFromUnicode)
For i = LBound(bytemsg) To UBound(bytemsg)
PostMessage hd, WM_CHAR, bytemsg(i), 0
Next i
sendkeys "~" '聊天之后需要回车发送聊天内容
End Sub
我试着排列sendkeys在块中的顺序,发现,无论放在什么地方,sendkeys总是发生在字符传送之后。
我也曾经把sendkeys单独写在另一个块中,但事件仍旧发生在发送字符之后。
求高手帮一下忙
这个sendkeys怎么才能发送在下面的命令之前?
有其他解决方法也行。