teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

6

抹消された内容の復元

2018/09/19 05:02

投稿

退会済みユーザー
title CHANGED
@@ -1,1 +1,1 @@
1
- あああああああああああああああああああああああああああああ
1
+ ダイアログの詳細について(FindWindow)
body CHANGED
@@ -1,1 +1,87 @@
1
+ 下記サイトを参考にダウンロード時のダイアログを操作しようと考えています。
2
+ http://note.phyllo.net/?eid=1106262
3
+ FindWindowで「ファイルのダウンロード」の記載のあるダイアログがあれば"S"を入力するようにしました。
4
+ ![イメージ説明](23b9c50323ae7707f8be0b5e3ad690c8.png)
5
+ ```C#
6
+ IntPtr hWnd2 = FindWindow(null, "ファイルのダウンロード");
7
+ if (hWnd2 != null)
8
+ {
9
+ SendKeys.SendWait("s");
10
+ }
11
+ ```
1
- あああああああああああああああああああああああああああああああああああああ
12
+ その後、下記のファイル名や保存先等を入力したいのですが、つまずいています。
13
+ ![イメージ説明](c070fdc53023da355c8c50eeb6203e5b.png)
14
+ 何かここを操作する方法はありませんでしょうか。
15
+ --------------------------------------------------------------------
16
+ 追記 2018/09/04 15:30
17
+ 回答いただきましたことを参考にSpy++をインストールし、上記を調べました。
18
+ ![イメージ説明](b241b5a94a6fb15840e1936796222972.png)
19
+ 調べた結果を参考に下記コードを作成しましたが、何も動いていません。
20
+ System.Threading.Thread.Sleep(500);で時間を長くしたり短くしても何か動かずエラーも出ていません。
21
+ 何か問題ある点等ありますでしょうか。
22
+ ```C#
23
+ IntPtr hWnd3 = FindWindow(null, "名前を付けて保存");
24
+ string filepath = @"c:\test\test.txt"; // 保存先
25
+ const uint WM_SETTEXT = 0x000c;
26
+ const uint WM_LBUTTONDOWN = 0x0201;
27
+ const uint WM_LBUTTONUP = 0x0202;
28
+ IntPtr hChild;
29
+ IntPtr hEdit;
30
+ hChild = FindWindowEx(hWnd3, IntPtr.Zero, "DUIViewWndClassName", null);
31
+ hChild = FindWindowEx(hChild, IntPtr.Zero, "DirectUIHWND", null);
32
+ hChild = FindWindowEx(hChild, IntPtr.Zero, "FloatNotifySink", null);
33
+ hChild = FindWindowEx(hChild, IntPtr.Zero, "ComboBox", null);
34
+ hEdit = FindWindowEx(hChild, IntPtr.Zero, "Edit", null);
35
+ // ファイル名を設定する
36
+ SendMessage(hChild, WM_SETTEXT, IntPtr.Zero, filepath);
37
+ System.Threading.Thread.Sleep(500);
38
+ // Saveボタンを見つける
39
+ hChild = IntPtr.Zero;
40
+ hChild = FindWindowEx(hWnd3, IntPtr.Zero, "Button", "保存(&S)");
41
+ // Saveボタンを押す
42
+ PostMessage(hChild, WM_LBUTTONDOWN, IntPtr.Zero, IntPtr.Zero);
43
+ PostMessage(hChild, WM_LBUTTONUP, IntPtr.Zero, IntPtr.Zero);
44
+ ```
45
+ ![イメージ説明](c8f04946cd7de7f301601c7ca19b3458.png)
46
+ 上記画像は上記ソースの
47
+ // ファイル名を設定する
48
+ まで実行した際の値になります。
49
+ そもそも取得出来ないのはわかっていますが、どうしてなのかがわからない状況です。
50
+ --------------------------------------------------------------------------------
51
+ 追記 2018/09/04 17:25
52
+ 取得出来ていない為、現状の状況を記載します。
53
+ ウインドウクラス名の指定をして間違っていた点等も修正したソースを記載します。
54
+ ```
55
+ //宣言文
56
+ [DllImport("user32.dll")]
57
+ static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
58
+ [DllImport("user32.dll")]
59
+ static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfeter, string lpszClass, string lpszWindow);
60
+ [DllImport("user32.dll")]
61
+ static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, IntPtr wParam, String lParam);
62
+ [DllImport("user32.dll")]
63
+ static extern bool PostMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam);
64
+ ```
65
+ ```C#
66
+ IntPtr hWnd3 = FindWindow("#32770", "名前を付けて保存");
67
+ string filepath = @"c:\test\test.txt"; // 保存先
68
+ const uint WM_SETTEXT = 0x000c;
69
+ const uint WM_LBUTTONDOWN = 0x0201;
70
+ const uint WM_LBUTTONUP = 0x0202;
71
+ IntPtr hChild;
72
+ IntPtr hEdit;
73
+ hChild = FindWindowEx(hWnd3, IntPtr.Zero, "DUIViewWndClassName", null);
74
+ hChild = FindWindowEx(hChild, IntPtr.Zero, "DirectUIHWND", null);
75
+ hChild = FindWindowEx(hChild, IntPtr.Zero, "FloatNotifySink", null);
76
+ hChild = FindWindowEx(hChild, IntPtr.Zero, "ComboBox", null);
77
+ hEdit = FindWindowEx(hChild, IntPtr.Zero, "Edit", null);
78
+ // ファイル名を設定する
79
+ SendMessage(hEdit, WM_SETTEXT, IntPtr.Zero, filepath);
80
+ System.Threading.Thread.Sleep(500);
81
+ // Saveボタンを見つける
82
+ hChild = IntPtr.Zero;
83
+ hChild = FindWindowEx(hWnd3, IntPtr.Zero, "Button", "保存(&S)");
84
+ // Saveボタンを押す
85
+ PostMessage(hChild, WM_LBUTTONDOWN, IntPtr.Zero, IntPtr.Zero);
86
+ PostMessage(hChild, WM_LBUTTONUP, IntPtr.Zero, IntPtr.Zero);
87
+ ```

5

ああああああ

2018/09/19 05:02

投稿

退会済みユーザー
title CHANGED
@@ -1,1 +1,1 @@
1
- ダイアログの詳細について(FindWindow)
1
+ あああああああああああああああああああああああああああああ
body CHANGED
@@ -1,105 +1,1 @@
1
- 下記サイトを参考にダウンロード時のダイアログを操作しようと考えています。
2
- http://note.phyllo.net/?eid=1106262
3
-
4
-
5
- FindWindowで「ファイルのダウンロード」の記載のあるダイアログがあれば"S"を入力するようにしました。
6
- ![イメージ説明](23b9c50323ae7707f8be0b5e3ad690c8.png)
7
- ```C#
8
- IntPtr hWnd2 = FindWindow(null, "ファイルのダウンロード");
9
- if (hWnd2 != null)
10
- {
11
- SendKeys.SendWait("s");
12
- }
13
- ```
14
-
15
-
16
- その後、下記のファイル名や保存先等を入力したいのですが、つまずいています。
1
+ あああああああああああああああああああああああああああああああああああああ
17
- ![イメージ説明](c070fdc53023da355c8c50eeb6203e5b.png)
18
- 何かここを操作する方法はありませんでしょうか。
19
-
20
-
21
- --------------------------------------------------------------------
22
- 追記 2018/09/04 15:30
23
- 回答いただきましたことを参考にSpy++をインストールし、上記を調べました。
24
- ![イメージ説明](b241b5a94a6fb15840e1936796222972.png)
25
- 調べた結果を参考に下記コードを作成しましたが、何も動いていません。
26
- System.Threading.Thread.Sleep(500);で時間を長くしたり短くしても何か動かずエラーも出ていません。
27
- 何か問題ある点等ありますでしょうか。
28
- ```C#
29
- IntPtr hWnd3 = FindWindow(null, "名前を付けて保存");
30
- string filepath = @"c:\test\test.txt"; // 保存先
31
- const uint WM_SETTEXT = 0x000c;
32
- const uint WM_LBUTTONDOWN = 0x0201;
33
- const uint WM_LBUTTONUP = 0x0202;
34
- IntPtr hChild;
35
- IntPtr hEdit;
36
-
37
- hChild = FindWindowEx(hWnd3, IntPtr.Zero, "DUIViewWndClassName", null);
38
- hChild = FindWindowEx(hChild, IntPtr.Zero, "DirectUIHWND", null);
39
- hChild = FindWindowEx(hChild, IntPtr.Zero, "FloatNotifySink", null);
40
- hChild = FindWindowEx(hChild, IntPtr.Zero, "ComboBox", null);
41
-
42
- hEdit = FindWindowEx(hChild, IntPtr.Zero, "Edit", null);
43
- // ファイル名を設定する
44
- SendMessage(hChild, WM_SETTEXT, IntPtr.Zero, filepath);
45
- System.Threading.Thread.Sleep(500);
46
- // Saveボタンを見つける
47
- hChild = IntPtr.Zero;
48
- hChild = FindWindowEx(hWnd3, IntPtr.Zero, "Button", "保存(&S)");
49
- // Saveボタンを押す
50
- PostMessage(hChild, WM_LBUTTONDOWN, IntPtr.Zero, IntPtr.Zero);
51
- PostMessage(hChild, WM_LBUTTONUP, IntPtr.Zero, IntPtr.Zero);
52
- ```
53
-
54
- ![イメージ説明](c8f04946cd7de7f301601c7ca19b3458.png)
55
- 上記画像は上記ソースの
56
- // ファイル名を設定する
57
- まで実行した際の値になります。
58
- そもそも取得出来ないのはわかっていますが、どうしてなのかがわからない状況です。
59
-
60
-
61
- --------------------------------------------------------------------------------
62
- 追記 2018/09/04 17:25
63
-
64
- 取得出来ていない為、現状の状況を記載します。
65
- ウインドウクラス名の指定をして間違っていた点等も修正したソースを記載します。
66
- ```
67
- //宣言文
68
- [DllImport("user32.dll")]
69
- static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
70
-
71
- [DllImport("user32.dll")]
72
- static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfeter, string lpszClass, string lpszWindow);
73
-
74
- [DllImport("user32.dll")]
75
- static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, IntPtr wParam, String lParam);
76
-
77
- [DllImport("user32.dll")]
78
- static extern bool PostMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam);
79
- ```
80
-
81
- ```C#
82
- IntPtr hWnd3 = FindWindow("#32770", "名前を付けて保存");
83
- string filepath = @"c:\test\test.txt"; // 保存先
84
- const uint WM_SETTEXT = 0x000c;
85
- const uint WM_LBUTTONDOWN = 0x0201;
86
- const uint WM_LBUTTONUP = 0x0202;
87
- IntPtr hChild;
88
- IntPtr hEdit;
89
-
90
- hChild = FindWindowEx(hWnd3, IntPtr.Zero, "DUIViewWndClassName", null);
91
- hChild = FindWindowEx(hChild, IntPtr.Zero, "DirectUIHWND", null);
92
- hChild = FindWindowEx(hChild, IntPtr.Zero, "FloatNotifySink", null);
93
- hChild = FindWindowEx(hChild, IntPtr.Zero, "ComboBox", null);
94
-
95
- hEdit = FindWindowEx(hChild, IntPtr.Zero, "Edit", null);
96
- // ファイル名を設定する
97
- SendMessage(hEdit, WM_SETTEXT, IntPtr.Zero, filepath);
98
- System.Threading.Thread.Sleep(500);
99
- // Saveボタンを見つける
100
- hChild = IntPtr.Zero;
101
- hChild = FindWindowEx(hWnd3, IntPtr.Zero, "Button", "保存(&S)");
102
- // Saveボタンを押す
103
- PostMessage(hChild, WM_LBUTTONDOWN, IntPtr.Zero, IntPtr.Zero);
104
- PostMessage(hChild, WM_LBUTTONUP, IntPtr.Zero, IntPtr.Zero);
105
- ```

4

ソースを修正

2018/09/19 03:17

投稿

退会済みユーザー
title CHANGED
File without changes
body CHANGED
@@ -55,4 +55,51 @@
55
55
  上記画像は上記ソースの
56
56
  // ファイル名を設定する
57
57
  まで実行した際の値になります。
58
- そもそも取得出来ないのはわかっていますが、どうしてなのかがわからない状況です。
58
+ そもそも取得出来ないのはわかっていますが、どうしてなのかがわからない状況です。
59
+
60
+
61
+ --------------------------------------------------------------------------------
62
+ 追記 2018/09/04 17:25
63
+
64
+ 取得出来ていない為、現状の状況を記載します。
65
+ ウインドウクラス名の指定をして間違っていた点等も修正したソースを記載します。
66
+ ```
67
+ //宣言文
68
+ [DllImport("user32.dll")]
69
+ static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
70
+
71
+ [DllImport("user32.dll")]
72
+ static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfeter, string lpszClass, string lpszWindow);
73
+
74
+ [DllImport("user32.dll")]
75
+ static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, IntPtr wParam, String lParam);
76
+
77
+ [DllImport("user32.dll")]
78
+ static extern bool PostMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam);
79
+ ```
80
+
81
+ ```C#
82
+ IntPtr hWnd3 = FindWindow("#32770", "名前を付けて保存");
83
+ string filepath = @"c:\test\test.txt"; // 保存先
84
+ const uint WM_SETTEXT = 0x000c;
85
+ const uint WM_LBUTTONDOWN = 0x0201;
86
+ const uint WM_LBUTTONUP = 0x0202;
87
+ IntPtr hChild;
88
+ IntPtr hEdit;
89
+
90
+ hChild = FindWindowEx(hWnd3, IntPtr.Zero, "DUIViewWndClassName", null);
91
+ hChild = FindWindowEx(hChild, IntPtr.Zero, "DirectUIHWND", null);
92
+ hChild = FindWindowEx(hChild, IntPtr.Zero, "FloatNotifySink", null);
93
+ hChild = FindWindowEx(hChild, IntPtr.Zero, "ComboBox", null);
94
+
95
+ hEdit = FindWindowEx(hChild, IntPtr.Zero, "Edit", null);
96
+ // ファイル名を設定する
97
+ SendMessage(hEdit, WM_SETTEXT, IntPtr.Zero, filepath);
98
+ System.Threading.Thread.Sleep(500);
99
+ // Saveボタンを見つける
100
+ hChild = IntPtr.Zero;
101
+ hChild = FindWindowEx(hWnd3, IntPtr.Zero, "Button", "保存(&S)");
102
+ // Saveボタンを押す
103
+ PostMessage(hChild, WM_LBUTTONDOWN, IntPtr.Zero, IntPtr.Zero);
104
+ PostMessage(hChild, WM_LBUTTONUP, IntPtr.Zero, IntPtr.Zero);
105
+ ```

3

画像の追加

2018/09/04 08:26

投稿

退会済みユーザー
title CHANGED
File without changes
body CHANGED
@@ -49,4 +49,10 @@
49
49
  // Saveボタンを押す
50
50
  PostMessage(hChild, WM_LBUTTONDOWN, IntPtr.Zero, IntPtr.Zero);
51
51
  PostMessage(hChild, WM_LBUTTONUP, IntPtr.Zero, IntPtr.Zero);
52
- ```
52
+ ```
53
+
54
+ ![イメージ説明](c8f04946cd7de7f301601c7ca19b3458.png)
55
+ 上記画像は上記ソースの
56
+ // ファイル名を設定する
57
+ まで実行した際の値になります。
58
+ そもそも取得出来ないのはわかっていますが、どうしてなのかがわからない状況です。

2

質問の追加

2018/09/04 07:53

投稿

退会済みユーザー
title CHANGED
File without changes
body CHANGED
@@ -15,4 +15,38 @@
15
15
 
16
16
  その後、下記のファイル名や保存先等を入力したいのですが、つまずいています。
17
17
  ![イメージ説明](c070fdc53023da355c8c50eeb6203e5b.png)
18
- 何かここを操作する方法はありませんでしょうか。
18
+ 何かここを操作する方法はありませんでしょうか。
19
+
20
+
21
+ --------------------------------------------------------------------
22
+ 追記 2018/09/04 15:30
23
+ 回答いただきましたことを参考にSpy++をインストールし、上記を調べました。
24
+ ![イメージ説明](b241b5a94a6fb15840e1936796222972.png)
25
+ 調べた結果を参考に下記コードを作成しましたが、何も動いていません。
26
+ System.Threading.Thread.Sleep(500);で時間を長くしたり短くしても何か動かずエラーも出ていません。
27
+ 何か問題ある点等ありますでしょうか。
28
+ ```C#
29
+ IntPtr hWnd3 = FindWindow(null, "名前を付けて保存");
30
+ string filepath = @"c:\test\test.txt"; // 保存先
31
+ const uint WM_SETTEXT = 0x000c;
32
+ const uint WM_LBUTTONDOWN = 0x0201;
33
+ const uint WM_LBUTTONUP = 0x0202;
34
+ IntPtr hChild;
35
+ IntPtr hEdit;
36
+
37
+ hChild = FindWindowEx(hWnd3, IntPtr.Zero, "DUIViewWndClassName", null);
38
+ hChild = FindWindowEx(hChild, IntPtr.Zero, "DirectUIHWND", null);
39
+ hChild = FindWindowEx(hChild, IntPtr.Zero, "FloatNotifySink", null);
40
+ hChild = FindWindowEx(hChild, IntPtr.Zero, "ComboBox", null);
41
+
42
+ hEdit = FindWindowEx(hChild, IntPtr.Zero, "Edit", null);
43
+ // ファイル名を設定する
44
+ SendMessage(hChild, WM_SETTEXT, IntPtr.Zero, filepath);
45
+ System.Threading.Thread.Sleep(500);
46
+ // Saveボタンを見つける
47
+ hChild = IntPtr.Zero;
48
+ hChild = FindWindowEx(hWnd3, IntPtr.Zero, "Button", "保存(&S)");
49
+ // Saveボタンを押す
50
+ PostMessage(hChild, WM_LBUTTONDOWN, IntPtr.Zero, IntPtr.Zero);
51
+ PostMessage(hChild, WM_LBUTTONUP, IntPtr.Zero, IntPtr.Zero);
52
+ ```

1

質問内容を詳しく記載

2018/09/04 06:35

投稿

退会済みユーザー
title CHANGED
File without changes
body CHANGED
@@ -1,8 +1,18 @@
1
- 下記画像のポップアップ画面について
2
- のダイアログはどう指定すれば良いで
1
+ 下記サイトを参考にダウンロード時のダイアログを操作と考えています
3
- FindWindow(null, "ファイルのダウンロード");
4
- 現在は上記で指定していますが、反応していません。
5
- nullの箇所もメモ帳は"Notepad"でしていると思いますがこの場合はどう記述するべきなのでしょうか。
2
+ http://note.phyllo.net/?eid=1106262
6
3
 
4
+
7
- グラム以前質問なってしまうかもれませんが、ご教授よろしくお願いいします
5
+ FindWindowで「ファイルのダウンード」記載のあるダイアログがあれば"S"を入力するようにしました。
8
- ![イメージ説明](db9e3739fd61f80f638952ae5210a24a.png)
6
+ ![イメージ説明](23b9c50323ae7707f8be0b5e3ad690c8.png)
7
+ ```C#
8
+ IntPtr hWnd2 = FindWindow(null, "ファイルのダウンロード");
9
+ if (hWnd2 != null)
10
+ {
11
+ SendKeys.SendWait("s");
12
+ }
13
+ ```
14
+
15
+
16
+ その後、下記のファイル名や保存先等を入力したいのですが、つまずいています。
17
+ ![イメージ説明](c070fdc53023da355c8c50eeb6203e5b.png)
18
+ 何かここを操作する方法はありませんでしょうか。