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

----------------- ScreenCapture.PowerPro -----------------------------
local hWnd,hDC,mDC,hBM,hOld,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)

if(arg(1))do
hWnd=Win.Handle("active")
else
hWnd=dll.call("GetDesktopWindow|ui")
endif

nWidth=hWnd.Width
nHeight=hWnd.Height

if(arg(1)==-1)do
local rect=dll.create_array(4,"i",0,0,"nWidth","nHeight")
dll.call("GetClientRect|ui a* b",hWnd,rect)
endif

hDC=dll.call("Get"++if(arg(1)==1,"Window")++"DC|ui",hWnd)
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,0,0,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",hWnd,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/
 



Reply via email to