--- In [email protected], "swzoh" <[EMAIL PROTECTED]> wrote:
>
> The usage is: .ScreenCapture(arg(1))
>
> if arg(1) is
> 1) 0 or "" or omitted, then captures the entire screen
> 2) 1, then captures the active window
> 3) -1, then captures the active client area
After a few more tests, I realized some people may prefer this one.
----------------- ScreenCapture.PowerPro -----------------------------
local hDC,mDC,hBM,hOld,nLeft,nTop,nWidth,nHeight
local sName,xName,pToken,pBitmap,nCodecs,nSize,ci,si
sName=?"C:\screen.bmp"
dll.call("MultiByteToWideChar|ui ui s i s i",;;+
0,0,"sName",-1,"xName",136)
nLeft=0
nTop=0
nWidth=xscreen
nHeight=yscreen
if(arg(1)==1)do
local hWnd=win.handle("active")
local rect=dll.create_array(4,"i")
dll.call("GetWindowRect|ui a* b" ,hWnd,rect)
nLeft=rect[1]
nTop=rect[2]
nWidth=rect[3] - rect[1]
nHeight=rect[4] - rect[2]
elseif(arg(1)==-1)
local hWnd=win.handle("active")
local rect=dll.create_array(4,"i")
dll.call("GetClientRect|ui a* b" ,hWnd,rect)
dll.call("ClientToScreen|ui a* b",hWnd,rect)
nLeft=rect[1]
nTop=rect[2]
nWidth=rect[3]
nHeight=rect[4]
endif
hDC=dll.call("GetDC|ui",0)
mDC=dll.call("CreateCompatibleDC|ui",hDC)
hBM=dll.call("CreateCompatibleBitmap|ui i i",hDC,nWidth,nHeight)
hOld=dll.call("SelectObject|ui ui",mDC,hBM)
dll.call("BitBlt|ui i i i i ui i i ui",;;+
mDC,0,0,nWidth,nHeight,hDC,nLeft,nTop,0x00CC0020 | 0x40000000)
//
si=dll.create_array(4,"i",1)
dll.call("gdiplus|GdiplusStartup|ui* a* ui","pToken",si,0)
dll.call("gdiplus|GdipCreateBitmapFromHBITMAP|ui ui ui*",;;+
hBM,0,"pBitmap")
dll.call("gdiplus|GdipGetImageEncodersSize|ui* ui*","nCodecs","nSize")
ci=dll.create_array(nSize/4+1,"i")
dll.call("gdiplus|GdipGetImageEncoders|ui ui a* b",nCodecs,nSize,ci)
for(local i=0;i<nCodecs;i++)
dll.call("WideCharToMultiByte|ui ui i i s i ui ui",;;+
0,0,ci[19*i+12],-1,"nSize",272,0,0)
if(index(nSize,file.type(sName)))
break
endfor
for(local j=4;j;j--)
si[j]=ci[j+i*76]
endfor
dll.call("gdiplus|GdipSaveImageToFile|ui s a* ui",;;+
pBitmap,"xName",si,0)
dll.call("gdiplus|GdipDisposeImage|ui",pBitmap)
dll.call("gdiplus|GdiplusShutdown|ui",pToken)
//
dll.call("SelectObject|ui ui",mDC,hOld)
dll.call("DeleteObject|ui",hBM)
dll.call("DeleteDC|ui",mDC)
dll.call("ReleaseDC|ui ui",0,hDC)
quit
----------------------------------------------------------------------
Sean
Attention: PowerPro's Web site has moved: http://www.ppro.org
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/power-pro/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/power-pro/join
(Yahoo! ID required)
<*> To change settings via email:
mailto:[EMAIL PROTECTED]
mailto:[EMAIL PROTECTED]
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/