下記サイトを参考にダウンロード時のダイアログを操作しようと考えています。
http://note.phyllo.net/?eid=1106262
FindWindowで「ファイルのダウンロード」の記載のあるダイアログがあれば"S"を入力するようにしました。
C#
1IntPtr hWnd2 = FindWindow(null, "ファイルのダウンロード"); 2if (hWnd2 != null) 3 { 4 SendKeys.SendWait("s"); 5 }
その後、下記のファイル名や保存先等を入力したいのですが、つまずいています。

何かここを操作する方法はありませんでしょうか。
追記 2018/09/04 15:30
回答いただきましたことを参考にSpy++をインストールし、上記を調べました。
調べた結果を参考に下記コードを作成しましたが、何も動いていません。
System.Threading.Thread.Sleep(500);で時間を長くしたり短くしても何か動かずエラーも出ていません。
何か問題ある点等ありますでしょうか。
C#
1IntPtr hWnd3 = FindWindow(null, "名前を付けて保存"); 2string filepath = @"c:\test\test.txt"; // 保存先 3 const uint WM_SETTEXT = 0x000c; 4 const uint WM_LBUTTONDOWN = 0x0201; 5 const uint WM_LBUTTONUP = 0x0202; 6 IntPtr hChild; 7 IntPtr hEdit; 8 hChild = FindWindowEx(hWnd3, IntPtr.Zero, "DUIViewWndClassName", null); 9 hChild = FindWindowEx(hChild, IntPtr.Zero, "DirectUIHWND", null); 10 hChild = FindWindowEx(hChild, IntPtr.Zero, "FloatNotifySink", null); 11 hChild = FindWindowEx(hChild, IntPtr.Zero, "ComboBox", null); 12 hEdit = FindWindowEx(hChild, IntPtr.Zero, "Edit", null); 13 // ファイル名を設定する 14 SendMessage(hChild, WM_SETTEXT, IntPtr.Zero, filepath); 15 System.Threading.Thread.Sleep(500); 16 // Saveボタンを見つける 17 hChild = IntPtr.Zero; 18 hChild = FindWindowEx(hWnd3, IntPtr.Zero, "Button", "保存(&S)"); 19 // Saveボタンを押す 20 PostMessage(hChild, WM_LBUTTONDOWN, IntPtr.Zero, IntPtr.Zero); 21 PostMessage(hChild, WM_LBUTTONUP, IntPtr.Zero, IntPtr.Zero);

上記画像は上記ソースの
// ファイル名を設定する
まで実行した際の値になります。
そもそも取得出来ないのはわかっていますが、どうしてなのかがわからない状況です。
追記 2018/09/04 17:25
取得出来ていない為、現状の状況を記載します。
ウインドウクラス名の指定をして間違っていた点等も修正したソースを記載します。
//宣言文 [DllImport("user32.dll")] static extern IntPtr FindWindow(string lpClassName, string lpWindowName); [DllImport("user32.dll")] static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfeter, string lpszClass, string lpszWindow); [DllImport("user32.dll")] static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, IntPtr wParam, String lParam); [DllImport("user32.dll")] static extern bool PostMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam);
C#
1IntPtr hWnd3 = FindWindow("#32770", "名前を付けて保存"); 2string filepath = @"c:\test\test.txt"; // 保存先 3 const uint WM_SETTEXT = 0x000c; 4 const uint WM_LBUTTONDOWN = 0x0201; 5 const uint WM_LBUTTONUP = 0x0202; 6 IntPtr hChild; 7 IntPtr hEdit; 8 hChild = FindWindowEx(hWnd3, IntPtr.Zero, "DUIViewWndClassName", null); 9 hChild = FindWindowEx(hChild, IntPtr.Zero, "DirectUIHWND", null); 10 hChild = FindWindowEx(hChild, IntPtr.Zero, "FloatNotifySink", null); 11 hChild = FindWindowEx(hChild, IntPtr.Zero, "ComboBox", null); 12 hEdit = FindWindowEx(hChild, IntPtr.Zero, "Edit", null); 13 // ファイル名を設定する 14 SendMessage(hEdit, WM_SETTEXT, IntPtr.Zero, filepath); 15 System.Threading.Thread.Sleep(500); 16 // Saveボタンを見つける 17 hChild = IntPtr.Zero; 18 hChild = FindWindowEx(hWnd3, IntPtr.Zero, "Button", "保存(&S)"); 19 // Saveボタンを押す 20 PostMessage(hChild, WM_LBUTTONDOWN, IntPtr.Zero, IntPtr.Zero); 21 PostMessage(hChild, WM_LBUTTONUP, IntPtr.Zero, IntPtr.Zero);
なにをやろうとしてるんでしょうか。説明が省略されすぎて意味不明です

FindWindowを利用してダイアログの操作をしたいです。上記写真は何で指定すればいいのでしょうか。
どういう状況の画面でしょうか。FindWindowsといっても、どこにある関数なのか不明です。質問自体を編集して、そこらへんの説明を加えてください

情報更新しました。この内容でも足りないでしょうか。

現在は[名前を付けて保存]画面の操作をしたいのですが、 初期はファイル名:にカーソルがあるので本日の日付をSendkeyで送信するように記載しましたが入力できませんでした。 ダイレクトに保存先パスやファイル名を入力する方法をご存知でしたらご教授お願いいたします。
おおもとになる hWnd3 が 0 ですね。クラス名を指定してやってみてください。それでも失敗するなら FindWindow の定義に失敗しているかもしれませんので、その部分を追記してください。

修正後のソースコードと宣言文も追記いたしました。ウインドウクラスも指定しましたが、変わらず動作しない状況です。どこか誤っている箇所等ございましたらご教授お願いいたします。
間違ってないように見えますね。うーん……
その前段階のダウンロード用ダイアログは操作できてますから、取れるように見えますね。代入と宣言を別にしてみる。。。とか?

回答3件
あなたの回答
tips
プレビュー