質問編集履歴
6
抹消された内容の復元
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
|
+

|
5
|
+
```C#
|
6
|
+
IntPtr hWnd2 = FindWindow(null, "ファイルのダウンロード");
|
7
|
+
if (hWnd2 != null)
|
8
|
+
{
|
9
|
+
SendKeys.SendWait("s");
|
10
|
+
}
|
11
|
+
```
|
1
|
-
|
12
|
+
その後、下記のファイル名や保存先等を入力したいのですが、つまずいています。
|
13
|
+

|
14
|
+
何かここを操作する方法はありませんでしょうか。
|
15
|
+
--------------------------------------------------------------------
|
16
|
+
追記 2018/09/04 15:30
|
17
|
+
回答いただきましたことを参考にSpy++をインストールし、上記を調べました。
|
18
|
+

|
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
|
+

|
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
ああああああ
title
CHANGED
@@ -1,1 +1,1 @@
|
|
1
|
-
|
1
|
+
あああああああああああああああああああああああああああああ
|
body
CHANGED
@@ -1,105 +1,1 @@
|
|
1
|
-
下記サイトを参考にダウンロード時のダイアログを操作しようと考えています。
|
2
|
-
http://note.phyllo.net/?eid=1106262
|
3
|
-
|
4
|
-
|
5
|
-
FindWindowで「ファイルのダウンロード」の記載のあるダイアログがあれば"S"を入力するようにしました。
|
6
|
-

|
7
|
-
```C#
|
8
|
-
IntPtr hWnd2 = FindWindow(null, "ファイルのダウンロード");
|
9
|
-
if (hWnd2 != null)
|
10
|
-
{
|
11
|
-
SendKeys.SendWait("s");
|
12
|
-
}
|
13
|
-
```
|
14
|
-
|
15
|
-
|
16
|
-
|
1
|
+
あああああああああああああああああああああああああああああああああああああ
|
17
|
-

|
18
|
-
何かここを操作する方法はありませんでしょうか。
|
19
|
-
|
20
|
-
|
21
|
-
--------------------------------------------------------------------
|
22
|
-
追記 2018/09/04 15:30
|
23
|
-
回答いただきましたことを参考にSpy++をインストールし、上記を調べました。
|
24
|
-

|
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
|
-

|
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
ソースを修正
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
画像の追加
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
|
+

|
55
|
+
上記画像は上記ソースの
|
56
|
+
// ファイル名を設定する
|
57
|
+
まで実行した際の値になります。
|
58
|
+
そもそも取得出来ないのはわかっていますが、どうしてなのかがわからない状況です。
|
2
質問の追加
title
CHANGED
File without changes
|
body
CHANGED
@@ -15,4 +15,38 @@
|
|
15
15
|
|
16
16
|
その後、下記のファイル名や保存先等を入力したいのですが、つまずいています。
|
17
17
|

|
18
|
-
何かここを操作する方法はありませんでしょうか。
|
18
|
+
何かここを操作する方法はありませんでしょうか。
|
19
|
+
|
20
|
+
|
21
|
+
--------------------------------------------------------------------
|
22
|
+
追記 2018/09/04 15:30
|
23
|
+
回答いただきましたことを参考にSpy++をインストールし、上記を調べました。
|
24
|
+

|
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
質問内容を詳しく記載
title
CHANGED
File without changes
|
body
CHANGED
@@ -1,8 +1,18 @@
|
|
1
|
-
下記画像のポップアップ画面について
|
2
|
-
|
1
|
+
下記サイトを参考にダウンロード時のダイアログを操作しようと考えています。
|
3
|
-
FindWindow(null, "ファイルのダウンロード");
|
4
|
-
現在は上記で指定していますが、反応していません。
|
5
|
-
|
2
|
+
http://note.phyllo.net/?eid=1106262
|
6
3
|
|
4
|
+
|
7
|
-
|
5
|
+
FindWindowで「ファイルのダウンロード」の記載のあるダイアログがあれば"S"を入力するようにしました。
|
8
|
-

|
7
|
+
```C#
|
8
|
+
IntPtr hWnd2 = FindWindow(null, "ファイルのダウンロード");
|
9
|
+
if (hWnd2 != null)
|
10
|
+
{
|
11
|
+
SendKeys.SendWait("s");
|
12
|
+
}
|
13
|
+
```
|
14
|
+
|
15
|
+
|
16
|
+
その後、下記のファイル名や保存先等を入力したいのですが、つまずいています。
|
17
|
+

|
18
|
+
何かここを操作する方法はありませんでしょうか。
|