调用SendMessage API问题 [英] Call SendMessage API Question
问题描述
你好!
Thanx到这个新组我终于在你们的帮助下得到了
这个中途工作..但最终动作仍然无效,点击
Button2通过SendMessage()。
私有声明自动功能FindWindow Lib" user32"别名FindWindowA
(ByVal lpClassName As String,ByVal lpWindowName As String)As Integer
私有声明自动函数FindWindowEx Lib" user32" (ByVal hWnd1 As
Long,ByVal hWnd2 As Long,ByVal lpsz1 As String,ByVal lpsz2 As String)As
Long
私有声明自动功能SendMessage Lib" user32" (ByVal hwnd As Long,
ByVal wMsg As Long,ByVal wParam As Long,ByVal lParam As Object)As long
Private Const WM_KEYDOWN =& H100
Private Const WM_KEYUP =& H101
Private Const VK_SPACE =& H20
Private Sub Button1_Click(ByVal sender As System.Object,ByVal e As
System.EventArgs)句柄
hWnd = FindWindow(vbNullString," Form1")
MsgBox(" Form1:"& hWnd)
hWndbutton = FindWindowEx(hWnd,0&," Button2", vbNullString)
MsgBox(" Button2:"& hWndbutton)
''想要在这里发送点击按钮号码2
MsgBox(SendMessage(hWndbutton,WM_KEYDOWN,VK_SPACE,0&)&""&
SendMessage(hWndbutton,WM_KEYUP,VK_SPACE,0& ;))
结束子
我从SendMEssage获得一个长号打电话..但Button2不是点击的b $ b ...
最好的问候/
Lars
Hello!
Thanx to this newgroup I have finally, with the help of you guys, gotten
this to work halfway.. but the final action is still not working, clicking
the "Button2" thru SendMessage().
Private Declare Auto Function FindWindow Lib "user32" Alias "FindWindowA"
(ByVal lpClassName As String, ByVal lpWindowName As String) As Integer
Private Declare Auto Function FindWindowEx Lib "user32" (ByVal hWnd1 As
Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As
Long
Private Declare Auto Function SendMessage Lib "user32" (ByVal hwnd As Long,
ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Object) As Long
Private Const WM_KEYDOWN = &H100
Private Const WM_KEYUP = &H101
Private Const VK_SPACE = &H20
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles
hWnd = FindWindow(vbNullString, "Form1")
MsgBox("Form1: " & hWnd)
hWndbutton = FindWindowEx(hWnd, 0&, "Button2", vbNullString)
MsgBox("Button2: " & hWndbutton)
''want to send a Click to button number 2 here
MsgBox(SendMessage(hWndbutton, WM_KEYDOWN, VK_SPACE, 0&) & " " &
SendMessage(hWndbutton, WM_KEYUP, VK_SPACE, 0&))
End Sub
I get a long number from both the SendMEssage Calls.. But the Button2 is not
clicked...
Best Regards/
Lars
推荐答案
我可能需要首先关注button2 ...也许吧?
" Lars Netzel" < UI **** @ adf.se>在消息中写道
news:uM ************** @ TK2MSFTNGP12.phx.gbl ...
I probably need to get the button2 in focus first... maybe?
"Lars Netzel" <ui****@adf.se> wrote in message
news:uM**************@TK2MSFTNGP12.phx.gbl...
你好!
Thanx到这个新组我终于在你们的帮助下得到了这个中途工作......但是最后的动作仍然没有用,点击
Button2。通过SendMessage()。
私有声明自动功能FindWindow Lib" user32"别名FindWindowA
(ByVal lpClassName As String,ByVal lpWindowName As String)As Integer
私有声明自动函数FindWindowEx Lib" user32" (ByVal hWnd1 As
Long,ByVal hWnd2 As Long,ByVal lpsz1 As String,ByVal lpsz2 As String)
As Long
私有声明自动功能SendMessage Lib" user32" (ByVal hwnd As
Long,ByVal wMsg As Long,ByVal wParam as Long,ByVal lParam As Object)As
私人Const WM_KEYDOWN =& H100
私有Const WM_KEYUP =& H101
私有Const VK_SPACE =& H20
私有子按钮1_Click(ByVal发送者为System.Object,ByVal e As
System.EventArgs)句柄
hWnd = FindWindow(vbNullString," Form1")
MsgBox(" Form1:"& hWnd)
hWndbutton = FindWindowEx(hWnd,0&," Button2",vbNullString)
MsgBox(" Button2:"& hWndbutton)
''想在这里发送一个点击按钮号2
MsgBox(发送消息(hWndbutton,WM_KEYDOWN,VK_SPACE,0&)&""&
SendMessage(hWndbutton,WM_KEYUP,VK_SPACE ,0&))
End Sub
我从SendMEssage电话中得到一个很长的号码..但Button2没有被点击......
最好的问候/
Lars
Hello!
Thanx to this newgroup I have finally, with the help of you guys, gotten
this to work halfway.. but the final action is still not working, clicking
the "Button2" thru SendMessage().
Private Declare Auto Function FindWindow Lib "user32" Alias "FindWindowA"
(ByVal lpClassName As String, ByVal lpWindowName As String) As Integer
Private Declare Auto Function FindWindowEx Lib "user32" (ByVal hWnd1 As
Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String)
As Long
Private Declare Auto Function SendMessage Lib "user32" (ByVal hwnd As
Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Object) As
Long
Private Const WM_KEYDOWN = &H100
Private Const WM_KEYUP = &H101
Private Const VK_SPACE = &H20
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles
hWnd = FindWindow(vbNullString, "Form1")
MsgBox("Form1: " & hWnd)
hWndbutton = FindWindowEx(hWnd, 0&, "Button2", vbNullString)
MsgBox("Button2: " & hWndbutton)
''want to send a Click to button number 2 here
MsgBox(SendMessage(hWndbutton, WM_KEYDOWN, VK_SPACE, 0&) & " " &
SendMessage(hWndbutton, WM_KEYUP, VK_SPACE, 0&))
End Sub
I get a long number from both the SendMEssage Calls.. But the Button2 is
not clicked...
Best Regards/
Lars
.net框架整数与旧的long相同。改变
你的渴望整数。难道没有button2.performclick为你工作吗?
http://msdn.microsoft.com/library/de...ClickTopic.asp
Ken
----------------------
" Lars Netzel" < UI **** @ adf.se>在消息中写道
news:uM ************** @ TK2MSFTNGP12.phx.gbl ...
Hi,
The .net framework integer is the same as the old long. Change
your longs to integers. Wouldn''t button2.performclick work for you?
http://msdn.microsoft.com/library/de...ClickTopic.asp
Ken
----------------------
"Lars Netzel" <ui****@adf.se> wrote in message
news:uM**************@TK2MSFTNGP12.phx.gbl...
你好!
Thanx到这个新组我终于在你们的帮助下得到了这个中途工作......但是最后的动作仍然没有用,点击
Button2。通过SendMessage()。
私有声明自动功能FindWindow Lib" user32"别名FindWindowA
(ByVal lpClassName As String,ByVal lpWindowName As String)As Integer
私有声明自动函数FindWindowEx Lib" user32" (ByVal hWnd1 As
Long,ByVal hWnd2 As Long,ByVal lpsz1 As String,ByVal lpsz2 As String)
As Long
私有声明自动功能SendMessage Lib" user32" (ByVal hwnd As
Long,ByVal wMsg As Long,ByVal wParam as Long,ByVal lParam As Object)As
私人Const WM_KEYDOWN =& H100
私有Const WM_KEYUP =& H101
私有Const VK_SPACE =& H20
私有子按钮1_Click(ByVal发送者为System.Object,ByVal e As
System.EventArgs)句柄
hWnd = FindWindow(vbNullString," Form1")
MsgBox(" Form1:"& hWnd)
hWndbutton = FindWindowEx(hWnd,0&," Button2",vbNullString)
MsgBox(" Button2:"& hWndbutton)
''想在这里发送一个点击按钮号2
MsgBox(发送消息(hWndbutton,WM_KEYDOWN,VK_SPACE,0&)&""&
SendMessage(hWndbutton,WM_KEYUP,VK_SPACE ,0&))
End Sub
我从SendMEssage电话中得到一个很长的号码..但Button2没有被点击......
最好的问候/
Lars
Hello!
Thanx to this newgroup I have finally, with the help of you guys, gotten
this to work halfway.. but the final action is still not working, clicking
the "Button2" thru SendMessage().
Private Declare Auto Function FindWindow Lib "user32" Alias "FindWindowA"
(ByVal lpClassName As String, ByVal lpWindowName As String) As Integer
Private Declare Auto Function FindWindowEx Lib "user32" (ByVal hWnd1 As
Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String)
As Long
Private Declare Auto Function SendMessage Lib "user32" (ByVal hwnd As
Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Object) As
Long
Private Const WM_KEYDOWN = &H100
Private Const WM_KEYUP = &H101
Private Const VK_SPACE = &H20
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles
hWnd = FindWindow(vbNullString, "Form1")
MsgBox("Form1: " & hWnd)
hWndbutton = FindWindowEx(hWnd, 0&, "Button2", vbNullString)
MsgBox("Button2: " & hWndbutton)
''want to send a Click to button number 2 here
MsgBox(SendMessage(hWndbutton, WM_KEYDOWN, VK_SPACE, 0&) & " " &
SendMessage(hWndbutton, WM_KEYUP, VK_SPACE, 0&))
End Sub
I get a long number from both the SendMEssage Calls.. But the Button2 is
not clicked...
Best Regards/
Lars
" Lars Netzel" < UI **** @ adf.se> schrieb:
"Lars Netzel" <ui****@adf.se> schrieb:
Thanx到这个新组我终于在你们的帮助下得到了这个中途工作......但是最后的动作仍然没有用,点击
Button2表示Button2。通过SendMessage()。
私有声明自动功能FindWindow Lib" user32"别名FindWindowA
(ByVal lpClassName As String,ByVal lpWindowName As String)As Integer
私有声明自动函数FindWindowEx Lib" user32" (ByVal hWnd1 As
Long,ByVal hWnd2 As Long,ByVal lpsz1 As String,ByVal lpsz2 As String)
As Long
私有声明自动功能SendMessage Lib" user32" (ByVal hwnd As
Long,ByVal wMsg As Long,ByVal wParam As Long,ByVal lParam As Object)As
Long
上面的声明是错误的。改为使用这个:
\\\
私有声明自动功能SendMessage Lib" user32.dll" (_
ByVal hwnd As IntPtr,_
ByVal wMsg As Int32,_
ByVal wParam As Int32,_
ByVal lParam作为Int32 _
)作为Int32
///
请注意''Long''映射到''Int64'',因此声明VB.NET和VB6不能互换。
私有Const WM_KEYDOWN =& H100
私有Const WM_KEYUP =& H101
私人Const VK_SPACE =& H20
=> ''Private Const ... As Int32 = ...''。
MsgBox(SendMessage(hWndbutton,WM_KEYDOWN,VK_SPACE,0&)&""&
SendMessage (hWndbutton,WM_KEYUP,VK_SPACE,0&))
Thanx to this newgroup I have finally, with the help of you guys, gotten
this to work halfway.. but the final action is still not working, clicking
the "Button2" thru SendMessage().
Private Declare Auto Function FindWindow Lib "user32" Alias "FindWindowA"
(ByVal lpClassName As String, ByVal lpWindowName As String) As Integer
Private Declare Auto Function FindWindowEx Lib "user32" (ByVal hWnd1 As
Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String)
As Long
Private Declare Auto Function SendMessage Lib "user32" (ByVal hwnd As
Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Object) As
Long
The declaration above is wrong. Use this one instead:
\\\
Private Declare Auto Function SendMessage Lib "user32.dll" ( _
ByVal hwnd As IntPtr, _
ByVal wMsg As Int32, _
ByVal wParam As Int32, _
ByVal lParam As Int32 _
) As Int32
///
Note that ''Long'' maps to ''Int64'', so declares for VB.NET and VB6 cannot be
interchanged.
Private Const WM_KEYDOWN = &H100
Private Const WM_KEYUP = &H101
Private Const VK_SPACE = &H20
=> ''Private Const ... As Int32 = ...''.
MsgBox(SendMessage(hWndbutton, WM_KEYDOWN, VK_SPACE, 0&) & " " &
SendMessage(hWndbutton, WM_KEYUP, VK_SPACE, 0&))
''0&''=> 0。
-
MS Herfried K. Wagner
MVP< URL:http:// dotnet.mvps.org/>
VB< URL:http://classicvb.org/petition/>
''0&'' => ''0''.
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
这篇关于调用SendMessage API问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!