質問編集履歴

6

抹消された内容の復元

2018/09/19 05:02

投稿

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

5

ああああああ

2018/09/19 05:02

投稿

退会済みユーザー
test CHANGED
@@ -1 +1 @@
1
- ダイアログの詳細について(FindWindow)
1
+ あああああああああああああああああああああああああああああ
test CHANGED
@@ -1,209 +1 @@
1
- 下記サイトを参考にダウンロード時のダイアログを操作しようと考えています。
2
-
3
- http://note.phyllo.net/?eid=1106262
4
-
5
-
6
-
7
-
8
-
9
- FindWindowで「ファイルのダウンロード」の記載のあるダイアログがあれば"S"を入力するようにしました。
10
-
11
- ![イメージ説明](23b9c50323ae7707f8be0b5e3ad690c8.png)
12
-
13
- ```C#
14
-
15
- IntPtr hWnd2 = FindWindow(null, "ファイルのダウンロード");
16
-
17
- if (hWnd2 != null)
18
-
19
- {
20
-
21
- SendKeys.SendWait("s");
22
-
23
- }
24
-
25
- ```
26
-
27
-
28
-
29
-
30
-
31
- その後、下記のファイル名や保存先等を入力したいのですが、つまずいています。
1
+ あああああああああああああああああああああああああああああああああああああ
32
-
33
- ![イメージ説明](c070fdc53023da355c8c50eeb6203e5b.png)
34
-
35
- 何かここを操作する方法はありませんでしょうか。
36
-
37
-
38
-
39
-
40
-
41
- --------------------------------------------------------------------
42
-
43
- 追記 2018/09/04 15:30
44
-
45
- 回答いただきましたことを参考にSpy++をインストールし、上記を調べました。
46
-
47
- ![イメージ説明](b241b5a94a6fb15840e1936796222972.png)
48
-
49
- 調べた結果を参考に下記コードを作成しましたが、何も動いていません。
50
-
51
- System.Threading.Thread.Sleep(500);で時間を長くしたり短くしても何か動かずエラーも出ていません。
52
-
53
- 何か問題ある点等ありますでしょうか。
54
-
55
- ```C#
56
-
57
- IntPtr hWnd3 = FindWindow(null, "名前を付けて保存");
58
-
59
- string filepath = @"c:\test\test.txt"; // 保存先
60
-
61
- const uint WM_SETTEXT = 0x000c;
62
-
63
- const uint WM_LBUTTONDOWN = 0x0201;
64
-
65
- const uint WM_LBUTTONUP = 0x0202;
66
-
67
- IntPtr hChild;
68
-
69
- IntPtr hEdit;
70
-
71
-
72
-
73
- hChild = FindWindowEx(hWnd3, IntPtr.Zero, "DUIViewWndClassName", null);
74
-
75
- hChild = FindWindowEx(hChild, IntPtr.Zero, "DirectUIHWND", null);
76
-
77
- hChild = FindWindowEx(hChild, IntPtr.Zero, "FloatNotifySink", null);
78
-
79
- hChild = FindWindowEx(hChild, IntPtr.Zero, "ComboBox", null);
80
-
81
-
82
-
83
- hEdit = FindWindowEx(hChild, IntPtr.Zero, "Edit", null);
84
-
85
- // ファイル名を設定する
86
-
87
- SendMessage(hChild, WM_SETTEXT, IntPtr.Zero, filepath);
88
-
89
- System.Threading.Thread.Sleep(500);
90
-
91
- // Saveボタンを見つける
92
-
93
- hChild = IntPtr.Zero;
94
-
95
- hChild = FindWindowEx(hWnd3, IntPtr.Zero, "Button", "保存(&S)");
96
-
97
- // Saveボタンを押す
98
-
99
- PostMessage(hChild, WM_LBUTTONDOWN, IntPtr.Zero, IntPtr.Zero);
100
-
101
- PostMessage(hChild, WM_LBUTTONUP, IntPtr.Zero, IntPtr.Zero);
102
-
103
- ```
104
-
105
-
106
-
107
- ![イメージ説明](c8f04946cd7de7f301601c7ca19b3458.png)
108
-
109
- 上記画像は上記ソースの
110
-
111
- // ファイル名を設定する
112
-
113
- まで実行した際の値になります。
114
-
115
- そもそも取得出来ないのはわかっていますが、どうしてなのかがわからない状況です。
116
-
117
-
118
-
119
-
120
-
121
- --------------------------------------------------------------------------------
122
-
123
- 追記 2018/09/04 17:25
124
-
125
-
126
-
127
- 取得出来ていない為、現状の状況を記載します。
128
-
129
- ウインドウクラス名の指定をして間違っていた点等も修正したソースを記載します。
130
-
131
- ```
132
-
133
- //宣言文
134
-
135
- [DllImport("user32.dll")]
136
-
137
- static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
138
-
139
-
140
-
141
- [DllImport("user32.dll")]
142
-
143
- static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfeter, string lpszClass, string lpszWindow);
144
-
145
-
146
-
147
- [DllImport("user32.dll")]
148
-
149
- static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, IntPtr wParam, String lParam);
150
-
151
-
152
-
153
- [DllImport("user32.dll")]
154
-
155
- static extern bool PostMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam);
156
-
157
- ```
158
-
159
-
160
-
161
- ```C#
162
-
163
- IntPtr hWnd3 = FindWindow("#32770", "名前を付けて保存");
164
-
165
- string filepath = @"c:\test\test.txt"; // 保存先
166
-
167
- const uint WM_SETTEXT = 0x000c;
168
-
169
- const uint WM_LBUTTONDOWN = 0x0201;
170
-
171
- const uint WM_LBUTTONUP = 0x0202;
172
-
173
- IntPtr hChild;
174
-
175
- IntPtr hEdit;
176
-
177
-
178
-
179
- hChild = FindWindowEx(hWnd3, IntPtr.Zero, "DUIViewWndClassName", null);
180
-
181
- hChild = FindWindowEx(hChild, IntPtr.Zero, "DirectUIHWND", null);
182
-
183
- hChild = FindWindowEx(hChild, IntPtr.Zero, "FloatNotifySink", null);
184
-
185
- hChild = FindWindowEx(hChild, IntPtr.Zero, "ComboBox", null);
186
-
187
-
188
-
189
- hEdit = FindWindowEx(hChild, IntPtr.Zero, "Edit", null);
190
-
191
- // ファイル名を設定する
192
-
193
- SendMessage(hEdit, WM_SETTEXT, IntPtr.Zero, filepath);
194
-
195
- System.Threading.Thread.Sleep(500);
196
-
197
- // Saveボタンを見つける
198
-
199
- hChild = IntPtr.Zero;
200
-
201
- hChild = FindWindowEx(hWnd3, IntPtr.Zero, "Button", "保存(&S)");
202
-
203
- // Saveボタンを押す
204
-
205
- PostMessage(hChild, WM_LBUTTONDOWN, IntPtr.Zero, IntPtr.Zero);
206
-
207
- PostMessage(hChild, WM_LBUTTONUP, IntPtr.Zero, IntPtr.Zero);
208
-
209
- ```

4

ソースを修正

2018/09/19 03:17

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -113,3 +113,97 @@
113
113
  まで実行した際の値になります。
114
114
 
115
115
  そもそも取得出来ないのはわかっていますが、どうしてなのかがわからない状況です。
116
+
117
+
118
+
119
+
120
+
121
+ --------------------------------------------------------------------------------
122
+
123
+ 追記 2018/09/04 17:25
124
+
125
+
126
+
127
+ 取得出来ていない為、現状の状況を記載します。
128
+
129
+ ウインドウクラス名の指定をして間違っていた点等も修正したソースを記載します。
130
+
131
+ ```
132
+
133
+ //宣言文
134
+
135
+ [DllImport("user32.dll")]
136
+
137
+ static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
138
+
139
+
140
+
141
+ [DllImport("user32.dll")]
142
+
143
+ static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfeter, string lpszClass, string lpszWindow);
144
+
145
+
146
+
147
+ [DllImport("user32.dll")]
148
+
149
+ static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, IntPtr wParam, String lParam);
150
+
151
+
152
+
153
+ [DllImport("user32.dll")]
154
+
155
+ static extern bool PostMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam);
156
+
157
+ ```
158
+
159
+
160
+
161
+ ```C#
162
+
163
+ IntPtr hWnd3 = FindWindow("#32770", "名前を付けて保存");
164
+
165
+ string filepath = @"c:\test\test.txt"; // 保存先
166
+
167
+ const uint WM_SETTEXT = 0x000c;
168
+
169
+ const uint WM_LBUTTONDOWN = 0x0201;
170
+
171
+ const uint WM_LBUTTONUP = 0x0202;
172
+
173
+ IntPtr hChild;
174
+
175
+ IntPtr hEdit;
176
+
177
+
178
+
179
+ hChild = FindWindowEx(hWnd3, IntPtr.Zero, "DUIViewWndClassName", null);
180
+
181
+ hChild = FindWindowEx(hChild, IntPtr.Zero, "DirectUIHWND", null);
182
+
183
+ hChild = FindWindowEx(hChild, IntPtr.Zero, "FloatNotifySink", null);
184
+
185
+ hChild = FindWindowEx(hChild, IntPtr.Zero, "ComboBox", null);
186
+
187
+
188
+
189
+ hEdit = FindWindowEx(hChild, IntPtr.Zero, "Edit", null);
190
+
191
+ // ファイル名を設定する
192
+
193
+ SendMessage(hEdit, WM_SETTEXT, IntPtr.Zero, filepath);
194
+
195
+ System.Threading.Thread.Sleep(500);
196
+
197
+ // Saveボタンを見つける
198
+
199
+ hChild = IntPtr.Zero;
200
+
201
+ hChild = FindWindowEx(hWnd3, IntPtr.Zero, "Button", "保存(&S)");
202
+
203
+ // Saveボタンを押す
204
+
205
+ PostMessage(hChild, WM_LBUTTONDOWN, IntPtr.Zero, IntPtr.Zero);
206
+
207
+ PostMessage(hChild, WM_LBUTTONUP, IntPtr.Zero, IntPtr.Zero);
208
+
209
+ ```

3

画像の追加

2018/09/04 08:26

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -101,3 +101,15 @@
101
101
  PostMessage(hChild, WM_LBUTTONUP, IntPtr.Zero, IntPtr.Zero);
102
102
 
103
103
  ```
104
+
105
+
106
+
107
+ ![イメージ説明](c8f04946cd7de7f301601c7ca19b3458.png)
108
+
109
+ 上記画像は上記ソースの
110
+
111
+ // ファイル名を設定する
112
+
113
+ まで実行した際の値になります。
114
+
115
+ そもそも取得出来ないのはわかっていますが、どうしてなのかがわからない状況です。

2

質問の追加

2018/09/04 07:53

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -33,3 +33,71 @@
33
33
  ![イメージ説明](c070fdc53023da355c8c50eeb6203e5b.png)
34
34
 
35
35
  何かここを操作する方法はありませんでしょうか。
36
+
37
+
38
+
39
+
40
+
41
+ --------------------------------------------------------------------
42
+
43
+ 追記 2018/09/04 15:30
44
+
45
+ 回答いただきましたことを参考にSpy++をインストールし、上記を調べました。
46
+
47
+ ![イメージ説明](b241b5a94a6fb15840e1936796222972.png)
48
+
49
+ 調べた結果を参考に下記コードを作成しましたが、何も動いていません。
50
+
51
+ System.Threading.Thread.Sleep(500);で時間を長くしたり短くしても何か動かずエラーも出ていません。
52
+
53
+ 何か問題ある点等ありますでしょうか。
54
+
55
+ ```C#
56
+
57
+ IntPtr hWnd3 = FindWindow(null, "名前を付けて保存");
58
+
59
+ string filepath = @"c:\test\test.txt"; // 保存先
60
+
61
+ const uint WM_SETTEXT = 0x000c;
62
+
63
+ const uint WM_LBUTTONDOWN = 0x0201;
64
+
65
+ const uint WM_LBUTTONUP = 0x0202;
66
+
67
+ IntPtr hChild;
68
+
69
+ IntPtr hEdit;
70
+
71
+
72
+
73
+ hChild = FindWindowEx(hWnd3, IntPtr.Zero, "DUIViewWndClassName", null);
74
+
75
+ hChild = FindWindowEx(hChild, IntPtr.Zero, "DirectUIHWND", null);
76
+
77
+ hChild = FindWindowEx(hChild, IntPtr.Zero, "FloatNotifySink", null);
78
+
79
+ hChild = FindWindowEx(hChild, IntPtr.Zero, "ComboBox", null);
80
+
81
+
82
+
83
+ hEdit = FindWindowEx(hChild, IntPtr.Zero, "Edit", null);
84
+
85
+ // ファイル名を設定する
86
+
87
+ SendMessage(hChild, WM_SETTEXT, IntPtr.Zero, filepath);
88
+
89
+ System.Threading.Thread.Sleep(500);
90
+
91
+ // Saveボタンを見つける
92
+
93
+ hChild = IntPtr.Zero;
94
+
95
+ hChild = FindWindowEx(hWnd3, IntPtr.Zero, "Button", "保存(&S)");
96
+
97
+ // Saveボタンを押す
98
+
99
+ PostMessage(hChild, WM_LBUTTONDOWN, IntPtr.Zero, IntPtr.Zero);
100
+
101
+ PostMessage(hChild, WM_LBUTTONUP, IntPtr.Zero, IntPtr.Zero);
102
+
103
+ ```

1

質問内容を詳しく記載

2018/09/04 06:35

投稿

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