Боюсь, не так просто делать то, что ты хочешь делать.Сначала вы должны найти дескриптор окна программы чтения PDF, встроенной в элемент управления WebBrowser.Вот пример кода о том, как это сделать:
Public Function GetPdfViewerHandle() As System.IntPtr
Dim tempHandle As System.IntPtr
'--------------------------------------
' get handle to pdf viewer
'--------------------------------------
'--------------------------------------
' first check for the foxit reader
'--------------------------------------
tempHandle = FindChildWindow(WebBrowser1.Handle, "AfxWnd42s", "Reader", 1, True)
If IntPtr.Zero.Equals(tempHandle) = True Then
'---------------------------------
' if not foxit, check for adobe
'---------------------------------
tempHandle = FindChildWindow(WebBrowser1.Handle, "AVL_AVVIEW", "AVPageView", 1, True)
End If
Return tempHandle
End Function
Public Shared Function FindChildWindow(ByVal hParent As IntPtr, ByVal P_childClass As String, ByVal P_childTitle As String, ByVal P_count As Integer, ByVal p_recursive As Boolean) As IntPtr
Dim hChild As IntPtr
Dim className As String
Dim title As String
Dim cnt As Integer
Dim tempPtr As IntPtr
Dim Declare Function FindWindowExA Lib "user32.dll" (ByVal hWnd1 As IntPtr, ByVal hWnd2 As Int32, ByVal lpsz1 As String, ByVal lpsz2 As String) As IntPtr
cnt = 0
hChild = FindWindowExA(hParent, 0, Nothing, Nothing)
While hChild.ToInt32 > 0
If P_childClass Is Nothing Then
className = GetClassName(hChild)
Else
className = GetClassName(hChild)
If P_childClass.Length < className.Length Then
className = className.Substring(0, P_childClass.Length)
End If
End If
If P_childTitle Is Nothing Then
title = GetWindowText(hChild).Replace("&", "")
Else
title = GetWindowText(hChild).Replace("&", "")
If P_childTitle.Length < title.Length Then
title = title.Substring(0, P_childTitle.Length)
End If
End If
Debug.WriteLine("hwnd=" + Hex$(hChild.ToInt32) + ", className = " + className + ", title = " + title)
If (String.Compare(className, P_childClass, True) = 0 And String.Compare(title, P_childTitle, True) = 0) Or (P_childClass = Nothing And String.Compare(title, P_childTitle, True) = 0) Or (String.Compare(className, P_childClass, True) = 0 And P_childTitle = Nothing) Then
cnt += 1
If cnt >= P_count Then
Return hChild
End If
End If
If p_recursive = True Then
tempPtr = FindChildWindow(hChild, P_childClass, P_childTitle, 1, p_recursive)
If IntPtr.Zero.Equals(tempPtr) = False Then
Return tempPtr
End If
End If
hChild = FindWindowExA(hParent, hChild.ToInt32, Nothing, Nothing)
End While
Return Nothing
End Function
Как только у вас есть дескриптор окна, есть много разных методов для поиска полей формы.Если вы знаете порядок вещей, вы можете просто начать посылать ключевые команды в дескриптор чтения PDF или использовать Spy ++, чтобы найти дескрипторы полей формы для ввода в них данных через функцию Win32Api SendMessageA:
Public Declare Function SendMessageA Lib "user32.dll" (ByVal hwnd As IntPtr, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer
asciiChar = CByte(Asc(data.Substring(0, 1)))
rc = SendMessageA(hwnd, WM_CHAR, asciiChar, 0)
Удачи.