私はprocess'esウィンドウの位置を取得する方法を知りたいです。私はインターネット上でそれを探してきましたが結果はありませんでした。感謝:)ウィンドウの位置を取得するには?
Process[] processes = Process.GetProcessesByName("notepad");
Process lol = processes[0];
IntPtr p = lol.MainWindowHandle;
私はprocess'esウィンドウの位置を取得する方法を知りたいです。私はインターネット上でそれを探してきましたが結果はありませんでした。感謝:)ウィンドウの位置を取得するには?
Process[] processes = Process.GetProcessesByName("notepad");
Process lol = processes[0];
IntPtr p = lol.MainWindowHandle;
これを試してみてください:
[DllImport("user32.dll", CharSet = CharSet.Auto)]
public static extern IntPtr FindWindow(string strClassName, string strWindowName);
[DllImport("user32.dll")]
public static extern bool GetWindowRect(IntPtr hwnd, ref Rect rectangle);
public struct Rect {
public int Left { get; set; }
public int Top { get; set; }
public int Right { get; set; }
public int Bottom { get; set; }
}
Process[] processes = Process.GetProcessesByName("notepad");
Process lol = processes[0];
IntPtr ptr = lol.MainWindowHandle;
Rect NotepadRect = new Rect();
GetWindowRect(ptr, ref NotepadRect);
using System.Runtime.InteropServices;
using System.Diagnostics;
public class GetNotePadLocation
{
[DllImport("user32.dll", CharSet = CharSet.Auto)]
public static extern IntPtr FindWindow(string strClassName, string strWindowName);
[DllImport("user32.dll")]
public static extern bool GetWindowRect(IntPtr hwnd, ref Rect rectangle);
public struct Rect
{
public int Left { get; set; }
public int Top { get; set; }
public int Right { get; set; }
public int Bottom { get; set; }
}
public static void NotePadLocation()
{
Process[] processes = Process.GetProcessesByName("notepad");
Process lol = processes[0];
IntPtr ptr = lol.MainWindowHandle;
Rect NotepadRect = new Rect();
GetWindowRect(ptr, ref NotepadRect);
}
}
私は欠けている部分を見つけたと思います。私はそれを修正しました... しかし、私は実際にすべての開いているメモ帳のウィンドウのこれらのプロパティを取得する方法とアクティブな1つの次元を取得する方法 助けてくれてありがとう... – hazem
DUP - http://stackoverflow.com/questions/1364440/how-to-get-and-set-window-position-他のアプリケーションをCシャープにする –
あなたはそれをどうしたいですか? [ウインドウでウィルス対策を終了する:)] –
あなたが考えることができるウインドウの位置を得るのに唯一の使用ですか? – Patryk