回答編集履歴
1
コード修正
test
CHANGED
@@ -66,7 +66,15 @@
|
|
66
66
|
|
67
67
|
timer.Dispose();
|
68
68
|
|
69
|
+
var scr = Screen.FromHandle(Handle);
|
70
|
+
|
71
|
+
getClickLocation(scr, p => {
|
72
|
+
|
73
|
+
Visible = true;
|
74
|
+
|
69
|
-
r
|
75
|
+
showProcessOfPoint(p);
|
76
|
+
|
77
|
+
});
|
70
78
|
|
71
79
|
};
|
72
80
|
|
@@ -74,20 +82,70 @@
|
|
74
82
|
|
75
83
|
}
|
76
84
|
|
77
|
-
|
78
|
-
|
85
|
+
|
86
|
+
|
79
|
-
private void
|
87
|
+
private void getClickLocation(Screen screen, Action<Point> clickHandler)
|
80
|
-
|
88
|
+
|
81
|
-
{
|
89
|
+
{
|
82
|
-
|
90
|
+
|
83
|
-
//
|
91
|
+
// スクリーンショットを全画面で表示
|
92
|
+
|
84
|
-
|
93
|
+
var screenShotForm = new Form();
|
94
|
+
|
95
|
+
screenShotForm.FormBorderStyle = FormBorderStyle.None;
|
96
|
+
|
97
|
+
screenShotForm.DesktopBounds = screen.Bounds;
|
98
|
+
|
99
|
+
|
100
|
+
|
85
|
-
var sc
|
101
|
+
var sc = screenShot(screen);
|
102
|
+
|
103
|
+
|
104
|
+
|
105
|
+
screenShotForm.Paint += (s, a) => {
|
106
|
+
|
107
|
+
a.Graphics.DrawImage(sc, 0, 0);
|
108
|
+
|
109
|
+
};
|
110
|
+
|
111
|
+
|
112
|
+
|
113
|
+
screenShotForm.MouseDown += (s, a) => {
|
114
|
+
|
115
|
+
if (a.Button == MouseButtons.Left) {
|
116
|
+
|
117
|
+
screenShotForm.Close();
|
118
|
+
|
119
|
+
clickHandler(a.Location);
|
120
|
+
|
121
|
+
}
|
122
|
+
|
123
|
+
};
|
124
|
+
|
125
|
+
|
126
|
+
|
127
|
+
screenShotForm.FormClosed += (s, a) => {
|
128
|
+
|
129
|
+
screenShotForm.Dispose();
|
130
|
+
|
131
|
+
screenShotForm = null;
|
132
|
+
|
133
|
+
};
|
134
|
+
|
135
|
+
|
136
|
+
|
137
|
+
screenShotForm.Show();
|
138
|
+
|
139
|
+
}
|
140
|
+
|
141
|
+
|
142
|
+
|
143
|
+
private Image screenShot(Screen screen)
|
144
|
+
|
145
|
+
{
|
86
146
|
|
87
147
|
var bounds = screen.Bounds;
|
88
148
|
|
89
|
-
|
90
|
-
|
91
149
|
var image = new Bitmap(bounds.Width, bounds.Height, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
|
92
150
|
|
93
151
|
|
@@ -106,75 +164,37 @@
|
|
106
164
|
|
107
165
|
}
|
108
166
|
|
109
|
-
|
110
|
-
|
111
|
-
// スクリーンショットを全画面で表示
|
112
|
-
|
113
|
-
var screenShotForm = new Form();
|
114
|
-
|
115
|
-
screenShotForm.FormBorderStyle = FormBorderStyle.None;
|
116
|
-
|
117
|
-
screenShotForm.DesktopBounds = bounds;
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
screenShotForm.Paint += (s, a) => {
|
122
|
-
|
123
|
-
|
167
|
+
return image;
|
124
|
-
|
168
|
+
|
125
|
-
|
169
|
+
}
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
170
|
+
|
130
|
-
|
171
|
+
|
172
|
+
|
131
|
-
|
173
|
+
private void showProcessOfPoint(Point p)
|
132
|
-
|
133
|
-
|
174
|
+
|
134
|
-
|
135
|
-
|
175
|
+
{
|
136
|
-
|
137
|
-
|
138
|
-
|
176
|
+
|
139
|
-
|
177
|
+
// クリックした位置からウィンドウ -> プロセスID -> プロセスを取得、表示
|
140
|
-
|
178
|
+
|
141
|
-
|
179
|
+
var hwnd = WindowFromPoint(p);
|
142
|
-
|
143
|
-
|
144
|
-
|
180
|
+
|
181
|
+
|
182
|
+
|
145
|
-
|
183
|
+
if (hwnd != IntPtr.Zero) {
|
146
|
-
|
184
|
+
|
147
|
-
|
185
|
+
if (GetWindowThreadProcessId(hwnd, out var processId) != 0) {
|
148
|
-
|
186
|
+
|
149
|
-
|
187
|
+
var process = Process.GetProcessById(processId);
|
150
|
-
|
188
|
+
|
151
|
-
|
189
|
+
MessageBox.Show(process.ProcessName);
|
152
|
-
|
153
|
-
}
|
154
|
-
|
155
|
-
} else {
|
156
|
-
|
157
|
-
MessageBox.Show("No Window");
|
158
|
-
|
159
|
-
}
|
160
190
|
|
161
191
|
}
|
162
192
|
|
193
|
+
} else {
|
194
|
+
|
195
|
+
MessageBox.Show("No Window");
|
196
|
+
|
163
|
-
}
|
197
|
+
}
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
screenShotForm.FormClosed += (s, a) => {
|
168
|
-
|
169
|
-
screenShotForm.Dispose();
|
170
|
-
|
171
|
-
screenShotForm = null;
|
172
|
-
|
173
|
-
};
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
screenShotForm.Show();
|
178
198
|
|
179
199
|
}
|
180
200
|
|