可以由QQ的主程序名,得到QQ的进程Process,然后由Process.MainWindowHandle 属性得到QQ主窗口的句柄,然后使用APIGetClientRect得到所在的矩形:[DllImport("user32.dll", CharSet=CharSet.Auto, ExactSpelling=true)] public static extern bool GetClientRect(IntPtr hWnd, [In, Out] ref RECT rect);[StructLayout(LayoutKind.Sequential)] public struct RECT { public int left; public int top; public int right; public int bottom; public RECT() { } public RECT(int left, int top, int right, int bottom) { this.left = left; this.top = top; this.right = right; this.bottom = bottom; } }
老大,我要的是屏幕中的位置呀,GetClientRect得到的是以他自己为中心的位置呀。 GetClientRect 结果, left = 0; right = 100; top = 0 ; bottom = 100; 刚好该窗体的高度是100, 宽度也是100呀。 例如他在屏幕中的最左边最顶点的位置是(20, 20) 要的结果是 left = 20; right = 120; top = 20 ; bottom = 120 ~~~~~~
别问我具体代码.哈哈....
作一个进程监视的程序
当发现QQ启动后,用楼上所说的API去获得
public static extern bool GetClientRect(IntPtr hWnd, [In, Out] ref RECT rect);[StructLayout(LayoutKind.Sequential)]
public struct RECT
{
public int left;
public int top;
public int right;
public int bottom;
public RECT()
{
}
public RECT(int left, int top, int right, int bottom)
{
this.left = left;
this.top = top;
this.right = right;
this.bottom = bottom;
}
}
GetClientRect 结果, left = 0; right = 100; top = 0 ; bottom = 100;
刚好该窗体的高度是100, 宽度也是100呀。
例如他在屏幕中的最左边最顶点的位置是(20, 20)
要的结果是 left = 20; right = 120; top = 20 ; bottom = 120
~~~~~~
QQ的高度+QQ的顶端=QQ的底部.
QQ的宽度+QQ的左端=QQ的右端.