回答編集履歴
2
見直しキャンペーン中
answer
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
わかりました!!
|
2
2
|
マニフェストに`disableWindowFiltering`の設定がいるようです。
|
3
|
-
|
4
3
|
[c++ - How to get a relational window tree like Spy++ does? - Stack Overflow](https://stackoverflow.com/questions/48613313/how-to-get-a-relational-window-tree-like-spy-does)
|
5
4
|
[アプリケーションマニフェスト - Win32 apps | Microsoft Docs](https://docs.microsoft.com/ja-jp/windows/win32/sbscs/application-manifests#disablewindowfiltering)
|
6
5
|
|
1
見直しキャンペーン中
answer
CHANGED
@@ -1,80 +1,77 @@
|
|
1
|
-
わかりました!!
|
2
|
-
マニフェストに`disableWindowFiltering`の設定がいるようです。
|
3
|
-
|
4
|
-
[c++ - How to get a relational window tree like Spy++ does? - Stack Overflow](https://stackoverflow.com/questions/48613313/how-to-get-a-relational-window-tree-like-spy-does)
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
using System;
|
16
|
-
using
|
17
|
-
using Windows.Win32;
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
<
|
64
|
-
|
65
|
-
|
66
|
-
<asmv3:windowsSettings
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
```
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
GetClassName
|
78
|
-
GetWindowText
|
79
|
-
GetWindowTextLength
|
1
|
+
わかりました!!
|
2
|
+
マニフェストに`disableWindowFiltering`の設定がいるようです。
|
3
|
+
|
4
|
+
[c++ - How to get a relational window tree like Spy++ does? - Stack Overflow](https://stackoverflow.com/questions/48613313/how-to-get-a-relational-window-tree-like-spy-does)
|
5
|
+
[アプリケーションマニフェスト - Win32 apps | Microsoft Docs](https://docs.microsoft.com/ja-jp/windows/win32/sbscs/application-manifests#disablewindowfiltering)
|
6
|
+
|
7
|
+
|
8
|
+
`DllImport`を書くのが面倒だったため↓を使用しました(使わない場合NativeMethods.txtは不要)
|
9
|
+
[NuGet Gallery | Microsoft.Windows.CsWin32 0.1.588-beta](https://www.nuget.org/packages/Microsoft.Windows.CsWin32/0.1.588-beta)
|
10
|
+
|
11
|
+
重要なのは**app.manifest**です。他は好きにしてください。
|
12
|
+
|
13
|
+
```cs
|
14
|
+
using System;
|
15
|
+
using System.Runtime.Versioning;
|
16
|
+
using Windows.Win32;
|
17
|
+
using Windows.Win32.Foundation;
|
18
|
+
|
19
|
+
namespace Questions364547
|
20
|
+
{
|
21
|
+
class Program
|
22
|
+
{
|
23
|
+
static void Main()
|
24
|
+
{
|
25
|
+
if (OperatingSystem.IsWindowsVersionAtLeast(5))
|
26
|
+
{
|
27
|
+
PInvoke.EnumWindows(CallBack, 0);
|
28
|
+
}
|
29
|
+
}
|
30
|
+
|
31
|
+
[SupportedOSPlatform("windows5.0")]
|
32
|
+
static BOOL CallBack(HWND handle, LPARAM param1)
|
33
|
+
{
|
34
|
+
unsafe
|
35
|
+
{
|
36
|
+
fixed (char* chars = new char[256])
|
37
|
+
{
|
38
|
+
if (PInvoke.GetClassName(handle, chars, 256) == 0) return true;
|
39
|
+
|
40
|
+
if (new string(chars) != "Windows.Internal.Shell.TabProxyWindow")
|
41
|
+
return true;
|
42
|
+
}
|
43
|
+
|
44
|
+
var size = PInvoke.GetWindowTextLength(handle) + 1;
|
45
|
+
fixed (char* chars = new char[size])
|
46
|
+
{
|
47
|
+
if (PInvoke.GetWindowText(handle, chars, size) == 0) return true;
|
48
|
+
|
49
|
+
Console.WriteLine($"タイトル: {new string(chars)}");
|
50
|
+
}
|
51
|
+
|
52
|
+
return true;
|
53
|
+
}
|
54
|
+
}
|
55
|
+
}
|
56
|
+
}
|
57
|
+
```
|
58
|
+
|
59
|
+
```xml:app.manifest
|
60
|
+
<?xml version="1.0" encoding="utf-8"?>
|
61
|
+
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">
|
62
|
+
|
63
|
+
<asmv3:application>
|
64
|
+
<asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2011/WindowsSettings">
|
65
|
+
<disableWindowFiltering>true</disableWindowFiltering>
|
66
|
+
</asmv3:windowsSettings>
|
67
|
+
</asmv3:application>
|
68
|
+
|
69
|
+
</assembly>
|
70
|
+
```
|
71
|
+
|
72
|
+
```txt:NativeMethods.txt
|
73
|
+
EnumWindows
|
74
|
+
GetClassName
|
75
|
+
GetWindowText
|
76
|
+
GetWindowTextLength
|
80
77
|
```
|