所以,我試圖捕獲一個窗口,它有兩個文本框,併發送一些文本到這兩個文本框。但是這兩個文本框沒有標題和相同的類名「編輯」。到目前爲止,我所能做的就是捕獲第一個文本框,就是這樣。如何捕獲兩個沒有標題和相同類的文本框?
粘貼在下面是我的代碼。
Imports System.Runtime.InteropServices
Imports System.Text
Public Class Form1
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As String, ByVal lpWindowName As String) As Integer
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
(ByVal hWnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, _
ByVal lParam As String) As Integer
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" _
(ByVal hWnd1 As Integer, ByVal hWnd2 As Integer, ByVal lpsz1 As String, _
ByVal lpsz2 As String) As Integer
Private Const WM_SETTEXT As Integer = &HC
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As _
System.EventArgs) Handles Button1.Click
Dim hwnd As Integer
Dim txt As Integer
Dim text As String
hwnd = FindWindow(vbNullString, "Description")
If hwnd <> Nothing Then
txt = FindWindowEx(hwnd, 0, "Edit", vbNullString)
If txt <> Nothing Then
text = "00000"
SendMessage(txt, WM_SETTEXT, 0, text)
End If
End If
End Sub
End Class
這是什麼都與「窗口API函數」做的,不是事實,其他你正在使用一些? –
對不起,如果我輸入了錯誤的標題 –