Gibts hier ne Art Spoiler? Damit der Post nicht endlos lang wird?
Unten einmal der fertige C# Code dafür.
|
C#-Quelltext
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
[DllImport("user32.dll")][return: MarshalAs(UnmanagedType.Bool)]
static extern bool GetWindowRect(HandleRef hWnd, out RECT lpRect);
private void button1_Click(object sender, EventArgs e){
IntPtr i = FindWindow("Screen Test");
RECT rc;
GetWindowRect(new HandleRef(this, this.Handle), out rc);
int width = rc.Right - rc.Left;
int height = rc.Bottom - rc.Top;
}
private IntPtr FindWindow(string title)
{
IntPtr ret = new IntPtr();
Process[] tempProcesses;
tempProcesses = Process.GetProcesses();
foreach (Process proc in tempProcesses)
{
if (proc.MainWindowTitle == title)
{
ret = proc.MainWindowHandle;
}
}
return ret;
}
[StructLayout(LayoutKind.Sequential)]
public struct RECT
{
public int Left;
public int Top;
public int Right;
public int Bottom;
}
|
So mach ich die Screens und ich glaub oben das brauch ich nicht komplett weil hab das gefunden (in Fett, vorher stand da Primary (was wohl der Desk ist)). Bin mir nur net sicher ob das Suchen über den Namen das wirklich Wahre ist.
int Width = System.Windows.Forms.Screen.
FromHandle(FindWindow("Screen Test")).Bounds.Width;
int Height = System.Windows.Forms.Screen.
FromHandle(FindWindow("Screen Test")).Bounds.Height;
size = new System.Drawing.Size(Width, Height);
Bitmap bitmap = new Bitmap(Width, Height);
{
using (Graphics graphics = Graphics.FromImage(bitmap))
{
graphics.CopyFromScreen(new Point(0, 0), new Point(0, 0), size);
}
}
Ist hier dran was auszusetzen?
mfg s0uuuL