永发信息网

如何获取指定窗口句柄的截图

答案:2  悬赏:60  手机版
解决时间 2021-02-01 21:41
  • 提问者网友:咪咪
  • 2021-02-01 13:53
用易语言怎么获取指定窗口句柄的窗口位置及截图?比如一个IE窗口句柄为123,怎么获取这个窗口的截图呢?如果这个窗口处于最小化或者被压在其他窗口下面怎么办?
最佳答案
  • 五星知识达人网友:风格不统一
  • 2021-02-01 14:18
不管什么语言。获取句柄。之后。可以进行一些可能的操作。 像你这种情况。你可以换一个思路去想想。向指定窗口 模拟 ALT+PRINTSCREEN 这样也可以实现。 不过这样就是有个缺点 。如果窗口不是最前。就没办法了。
全部回答
  • 1楼网友:慢性怪人
  • 2021-02-01 14:56
'添加如下声明 private declare function bringwindowtotop lib "user32" (byval hwnd as long) as long private declare function getwindowrect lib "user32" (byval hwnd as long, lprect as rect) as long private declare function getwindowdc lib "user32" (byval hwnd as long) as long private declare function releasedc lib "user32" (byval hwnd as long, byval hdc as long) as long private declare function bitblt lib "gdi32" (byval hdestdc as long, byval x as long, byval y as long, byval nwidth as long, byval nheight as long, byval hsrcdc as long, byval xsrc as long, byval ysrc as long, byval dwrop as long) as long private type rect left as long top as long right as long bottom as long end type '添加这个函数 private sub getwndpic(wnd as long, pic as picturebox) dim r as rect, dc as long getwindowrect wnd, r '获取指定窗口的左上角、右下角位置(以便获取其大小) dc = getwindowdc(wnd) '得到dc with pic .autoredraw = true: .borderstyle = 0 .parent.scalemode = vbpixels .move .left, .top, r.right - r.left, r.bottom - r.top '使picturebox适合大小 bringwindowtotop wnd '目标窗口提到前面(非置顶) bitblt .hdc, 0, 0, .width, .height, dc, 0, 0, vbsrccopy '复制绘图 end with releasedc wnd, dc '释放 end sub '调用示例(把句柄131454的程序窗口截图放到picture1中) getwndpic 131454, picture1
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯