c# 屏幕捕捉(捕捉窗口特定元素)??在现等待。。。。 EPsnap是个抓屏软件,其中捕捉“窗口元素”这个功能C# 怎末实现这个功能:比如打开一个网页,当选择捕捉“窗口元素”模式,则当鼠标放到页面一个图片上她就自动获取了这个图片的区域(句柄?)然后就能捕捉它并保持为图像文件? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 使用Win32API函数: WindowFromPoint,可以通过鼠标位置获取窗体的句柄。用法可以参考MSDN,或者baidu,search.但要注意,当窗体失去焦点时,窗体是没办法触发事件的,有两个办法解决:1. 使用一个Timer,在Timer中调用WindowFromPoint2. 使用HOOK. WindowFromPoint 是这能获取本程序窗口控件吗?我需要获取其他程序窗口的怎么办?HOOK能吗?找不到具体例子请高手继续指点啊 ! //获取屏幕1024*768图像 [System.Runtime.InteropServices.DllImport("gdi32.dll")] public static extern int BitBlt(IntPtr hdcDest, int nXDest, int nYDest, int nWidth, int nHeight, IntPtr hdcSrc, int nXSrc, int nYSrc, UInt32 dwRop); [System.Runtime.InteropServices.DllImportAttribute("gdi32.dll")] public static extern IntPtr CreateDC(string lpszDriver, string lpszDevice, string lpszOutput, int lpInitData); [System.Runtime.InteropServices.DllImport("gdi32.dll")] public static extern IntPtr CreateCompatibleDC(IntPtr hdc); [System.Runtime.InteropServices.DllImport("gdi32.dll")] public static extern IntPtr CreateCompatibleBitmap(IntPtr hdc, int nWidth, int nHeight); [System.Runtime.InteropServices.DllImport("gdi32.dll")] public static extern IntPtr SelectObject(IntPtr hdc, IntPtr hgdiobj); [System.Runtime.InteropServices.DllImport("gdi32.dll")] public static extern int DeleteDC(IntPtr hdc); [DllImport("user32.dll")] public static extern bool ReleaseDC( IntPtr hwnd, IntPtr hdc ); [DllImport("gdi32.dll")] public static extern bool DeleteObject( IntPtr hdc ); /// <summary> /// 截取屏幕图像 /// </summary> /// <param name="Width"></param> /// <param name="Height"></param> /// <returns></returns> public Bitmap fullphoto(int Width,int Height,int x,int y) { Bitmap bitmap; //try //{ IntPtr hScreenDc = CreateDC("DISPLAY", null, null, 0); // 创建桌面句柄 IntPtr hMemDc = CreateCompatibleDC(hScreenDc); // 创建与桌面句柄相关连的内存DC IntPtr hBitmap = CreateCompatibleBitmap(hScreenDc, Width, Height); IntPtr hOldBitmap = SelectObject(hMemDc, hBitmap); BitBlt(hMemDc, x, y, Width, Height, hScreenDc, x, y, (UInt32)0xcc0020); IntPtr map = SelectObject(hMemDc, hOldBitmap); bitmap = Bitmap.FromHbitmap(map); ReleaseDC(hBitmap, hScreenDc); DeleteDC(hScreenDc);//删除用过的对象 DeleteDC(hMemDc);//删除用过的对象 DeleteDC(hOldBitmap); DeleteObject(hBitmap); //} //catch (Exception wx) //{ // return null; //} // number= number +1; // bitmap.Save("screen" + number + ".bmp"); return bitmap; } 就像 SPY++那样恐怕有难度了 WindowFromPoint可以得到窗体的Handle,其他进程的也可以然后用GetWindowRect可以得到窗体的位置及大小,然后你画边框、截图随便你搞了 你是不是要找相当于QQ截图功能,我有看到过这个问题,我推荐你去看看,会有你要的答案http://www.cnblogs.com/stg609/archive/2008/03/19/1113694.html (1)对于winform,我们可以用WindowFromPoint; (2)对于WebForm, 我们用IHTMLDocument2.elementFromPoint 关于DataTable往数据库中更新的问题!! C#文件下载代码。哪里出错了? 项目开发困惑(c# +oracle) 本人用了一年时间终于写完了。现提供整套系统源码与制作方法2。 Oracle 数据库连接 关于绑定数据的问题 请问托管堆和非托管类型有什么区别,请各具几个例子,头疼! 怎么在web service中传递我自己定义的类 求指点,C#如何获得任务管理器里应用程序的状态 请问DATAVIEW或TABLE中如何得到当前记录的索引(index)?? C# 应用程序 中文编码问题 c#:函数调用问题。
1. 使用一个Timer,在Timer中调用WindowFromPoint
2. 使用HOOK.
我需要获取其他程序窗口的怎么办?HOOK能吗?
找不到具体例子
请高手继续指点啊 !
[System.Runtime.InteropServices.DllImport("gdi32.dll")]
public static extern int BitBlt(IntPtr hdcDest, int nXDest, int nYDest, int nWidth, int nHeight, IntPtr hdcSrc, int nXSrc, int nYSrc, UInt32 dwRop); [System.Runtime.InteropServices.DllImportAttribute("gdi32.dll")]
public static extern IntPtr CreateDC(string lpszDriver, string lpszDevice, string lpszOutput, int lpInitData); [System.Runtime.InteropServices.DllImport("gdi32.dll")]
public static extern IntPtr CreateCompatibleDC(IntPtr hdc); [System.Runtime.InteropServices.DllImport("gdi32.dll")]
public static extern IntPtr CreateCompatibleBitmap(IntPtr hdc, int nWidth, int nHeight); [System.Runtime.InteropServices.DllImport("gdi32.dll")]
public static extern IntPtr SelectObject(IntPtr hdc, IntPtr hgdiobj); [System.Runtime.InteropServices.DllImport("gdi32.dll")]
public static extern int DeleteDC(IntPtr hdc);
[DllImport("user32.dll")]
public static extern bool ReleaseDC(
IntPtr hwnd, IntPtr hdc
);
[DllImport("gdi32.dll")]
public static extern bool DeleteObject(
IntPtr hdc
);
/// <summary>
/// 截取屏幕图像
/// </summary>
/// <param name="Width"></param>
/// <param name="Height"></param>
/// <returns></returns>
public Bitmap fullphoto(int Width,int Height,int x,int y)
{
Bitmap bitmap;
//try
//{
IntPtr hScreenDc = CreateDC("DISPLAY", null, null, 0); // 创建桌面句柄
IntPtr hMemDc = CreateCompatibleDC(hScreenDc); // 创建与桌面句柄相关连的内存DC
IntPtr hBitmap = CreateCompatibleBitmap(hScreenDc, Width, Height);
IntPtr hOldBitmap = SelectObject(hMemDc, hBitmap);
BitBlt(hMemDc, x, y, Width, Height, hScreenDc, x, y, (UInt32)0xcc0020);
IntPtr map = SelectObject(hMemDc, hOldBitmap);
bitmap = Bitmap.FromHbitmap(map);
ReleaseDC(hBitmap, hScreenDc);
DeleteDC(hScreenDc);//删除用过的对象
DeleteDC(hMemDc);//删除用过的对象
DeleteDC(hOldBitmap);
DeleteObject(hBitmap);
//}
//catch (Exception wx)
//{
// return null;
//}
// number= number +1;
// bitmap.Save("screen" + number + ".bmp");
return bitmap;
}
恐怕有难度了
然后用GetWindowRect可以得到窗体的位置及大小,然后你画边框、截图随便你搞了