我用VB写了一个sendmessage的测试程序,向一个名为“测试窗体”的的窗体(vb.net编写),但不起作用
PrivateDeclareFunctionSendMessageLib"user32"Alias"SendMessageA"(ByValhwndAsLong,ByVal...
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
'Private Const vbKeyA As Long = &H65
Private Const WM_KEYDOWN = &H100
Const WM_ACTIVATE = &H6
Const WM_LBUTTONUP = &H202
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Sub Command1_Click()
Dim hwnd As Long
hwnd = FindWindow(vbNullString, "测试窗体")
If hwnd <> 0 Then
MsgBox "1"
SendMessage hwnd, WM_KEYDOWN, vbKeyB, 0
Else
MsgBox "2"
End If
以上为VB6编写的测试程序代码,接收信息的窗体是VB.NET,我向“测试窗体“发出一个按下B键的信息,测试窗体应该会弹出对话框,但是测试窗体没有任何反映,麻烦大家给我指示下这是怎么回事? 展开
'Private Const vbKeyA As Long = &H65
Private Const WM_KEYDOWN = &H100
Const WM_ACTIVATE = &H6
Const WM_LBUTTONUP = &H202
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Sub Command1_Click()
Dim hwnd As Long
hwnd = FindWindow(vbNullString, "测试窗体")
If hwnd <> 0 Then
MsgBox "1"
SendMessage hwnd, WM_KEYDOWN, vbKeyB, 0
Else
MsgBox "2"
End If
以上为VB6编写的测试程序代码,接收信息的窗体是VB.NET,我向“测试窗体“发出一个按下B键的信息,测试窗体应该会弹出对话框,但是测试窗体没有任何反映,麻烦大家给我指示下这是怎么回事? 展开
3个回答
展开全部
真实按下B键,VB.NET窗体有反应吗?特别是其处于后台的情况下
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
SendMessage hwnd, WM_KEYDOWN, vbKeyB, 0
SendMessage hwnd, WM_KEYUP, vbKeyB, 0
SendMessage hwnd, WM_KEYUP, vbKeyB, 0
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询