[ファイルを開く]ダイアログを識別し、[ファイル名]フィールドにメッセージを送信する方法を見つけようとしています。その後、ボタンに「Enter」キーまたは「Open」コマンドを送信する必要があります。
私はこれをVBで行っていますが、誰かがC#でも助けてくれれば、私は対処できると確信しています。
私はこの日中APIを掘り下げて、いくつかの可能性を考え出しましたが、DotNet4でこれを実装する方法に慣れていません。以前はVB6でAPIを使用していましたが、現在は少し異なっているようです。
誰かが私に小さな例を提供してくれたら、私は感謝するでしょう。
私が見たAPIのいくつかは、FindWindowとFindWindowExです。
編集:
見る価値のあるコードを見つけました。このコードは、モジュール内で使用する必要があります。より多くの答えを見つけたら、もっと投稿します。
Imports System.Runtime.InteropServices
Imports System.Text
Module modEnumWindows
Private windowList As New ArrayList
Private errMessage As String
Public Delegate Function MyDelegateCallBack(ByVal hwnd As Integer, ByVal lParam As Integer) As Boolean
Declare Function EnumWindows Lib "user32" (ByVal x As MyDelegateCallBack, ByVal y As Integer) As Integer
Declare Auto Function GetClassName Lib "user32" _
(ByVal hWnd As IntPtr, _
ByVal lpClassName As System.Text.StringBuilder, _
ByVal nMaxCount As Integer) As Integer
Declare Auto Function GetWindowText Lib "user32" _
(ByVal hWnd As IntPtr, _
ByVal lpClassName As System.Text.StringBuilder, _
ByVal nMaxCount As Integer) As Integer
Private Function EnumWindowProc(ByVal hwnd As Integer, ByVal lParam As Integer) As Boolean
'working vars
Dim sTitle As New StringBuilder(255)
Dim sClass As New StringBuilder(255)
Try
Call GetClassName(hwnd, sClass, 255)
Call GetWindowText(hwnd, sTitle, 255)
windowList.Add(sClass.ToString & ", " & hwnd & ", " & sTitle.ToString)
Catch ex As Exception
errMessage = ex.Message
EnumWindowProc = False
Exit Function
End Try
EnumWindowProc = True
End Function
Public Function getWindowList(ByRef wList As ArrayList, Optional ByVal errorMessage As String = "") As Boolean
windowList.Clear()
Try
Dim del As MyDelegateCallBack
del = New MyDelegateCallBack(AddressOf EnumWindowProc)
EnumWindows(del, 0)
getWindowList = True
Catch ex As Exception
getWindowList = False
errorMessage = errMessage
Exit Function
End Try
'wList.Clear()
wList = windowList
End Function
End Module
これを使用することにより、ウィンドウテキスト、HWND、およびクラスを識別できます。これが人々に少し役立つことを願っています。次のステップは、データを送信したいフィールドを特定することです。