我有一个 3 形式的项目。
我希望 form3 使用 sendmessage 到 form2 但我无法让它工作。如果它有任何不同,form2 上有一个 flash 对象(特别是游戏),我想将这些键发送给它。
这是我拥有的一些东西,但我不知道为什么它不起作用:
Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As String, ByVal lpwindowname As String) As IntPtr
Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
(ByVal hWnd As IntPtr, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As IntPtr
Const WM_KEYDOWN As Integer = &H100
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
Dim destination As IntPtr = FindWindow(Nothing, Window)
SendMessage(destination, WM_KEYDOWN, Keys.Down, 0)
End Sub
澄清窗口是一个包含 form2.text 的字符串。