Sign in to follow this  
Followers 0
Hasher

Screen Capture

3 posts in this topic

Hi this is one of my first posts aand I am not so good with anything to do with DLL's but below is my attempt at a screen capture app. Borrowed some code off the forum and wrote some of my own.

The probelm I am having is :

C:\Documents and Settings\user\Desktop\scr.au3 (44) : ==> AutoIt has encountered a fatal crash as a result of:

Unable to execute DLLCall.:

DllCall ( "olepro32.dll" , "int" , "OleCreatePictureIndirect" , "ptr" , DllStructGetPtr($myPic)

[code]
dim $myPicObject
; Screenshot via Dll

$hwnd = DllCall("user32.dll","hwnd","GetDesktopWindow") 
; get handle to entire screen 

$DC = DllCall("user32.dll","ptr","GetWindowDC","hwnd",$hwnd[0]) 
; get device context for picture information

$lpRect = DllStructCreate("int;int;int;int") 
; create DllStruct for GetWindowRect call

DllCall("user32.dll","int","GetWindowRect","hwnd",$hwnd[0],"ptr",DllStructGetPtr($lpRect)) 
; get coordinates from upper-left and lower-right corner

$cDC = DllCall("gdi32.dll","ptr","CreateCompatibleDC","ptr",$DC[0]) 
; create compatible DC

$hbmp = DllCall("gdi32.dll","hwnd","CreateCompatibleBitmap","ptr",$DC[0],"int",DllStructGetData($lpRect,3),"int",DllStructGetData($lpRect,3))
; create compatible bitmap

DllCall("gdi32.dll","hwnd","SelectObject","ptr",$cDC[0],"hwnd",$hbmp[0])
; select bitmap to device context

DllCall("gdi32.dll","int","BitBlt","ptr",$cDC[0],"int",0,"int",0,"int",DllStructGetData($lpRect,3),"int",DllStructGetData($lpRect,3),"ptr",$DC[0],"int",0,"int",0,"int",0x00CC0020)
; copy picture information from the screen to device context in memory

Sleep(5000)
; break for doing anything on screen

DllCall("gdi32.dll","int","BitBlt","ptr",$DC[0],"int",0,"int",0,"int",DllStructGetData($lpRect,3),"int",DllStructGetData($lpRect,3),"ptr",$cDC[0],"int",0,"int",0,"int",0x00CC0020)
; restore previous saved screen

DllCall("user32.dll","int","ReleaseDC","hwnd",$hwnd[0],"ptr",$cDC[0]); release device context for use by other apps

DllCall("user32.dll","int","ReleaseDC","hwnd",$hwnd[0],"ptr",$DC[0]); release device context for use by other apps

$myPic = DllStructCreate ( "uint;uint;uint;uint;uint")
DllStructSetData($myPic,2,1)
DllStructSetData($myPic,3, $hbmp)
DllStructSetData($myPic,4,0)
DllStructSetData($myPic,5,0)
DllStructSetData($myPic,1,DllStructGetSize($myPic))
DllCall ( "olepro32.dll" , "int" , "OleCreatePictureIndirect" , "ptr" , DllStructGetPtr($myPic))

$myIID = DllStructCreate ( "uint;ushort;ushort;ubyte;ubyte;ubyte;ubyte;ubyte;ubyte;ubyte;ubyte")

DllStructSetData ($myIID , 1 , 0x20400 )        
DllStructSetData ( $myIID , 4 ,0xC0 )
DllStructSetData ( $myIID , 11 , 0x46 )
DllCall ( "olepro32.dll" , "int" , "OleCreatePictureIndirect" , "ptr" , DllStructGetPtr($myPic) , "ptr" , DllStructGetPtr($myIID) , "int" , 1 , "ptr" , $myPicObject )
DllCall ( "oleaut32.dll" , "uint" , "OleSavePictureFile" , "ptr" , $myPicObject , "wstr" , "MYBMPFILE.BMP" )

Any help with what I am doing wrong would be appeicaited :-)

Also if anyone has a Bmp to Jpg function it would make my day!!!

Paul


Firefox's secret is the same as Jessica Simpson's: its effortless, glamorous style is the result of — shhh — extensions!

Share this post


Link to post
Share on other sites



I don't think you're calling the API with the correct parameters. Here is the API prototype for OleCreatePictureIndirect from MSDN:

STDAPI OleCreatePictureIndirect( 
  PICTDESC* pPictDesc,  //Pointer to the structure of parameters for picture
  REFIID riid, //Reference to the identifier of the interface
  BOOL fOwn, //Whether the picture is to be destroyed
  VOID** ppvObj  //Address of output variable that receives the interface pointer requested in riid
)

So this won't work:

DllCall ( "olepro32.dll" , "int" , "OleCreatePictureIndirect" , "ptr" , DllStructGetPtr($myPic))

Auto3Lib: A library of over 1200 functions for AutoIt

Share this post


Link to post
Share on other sites

http://www.autoitscript.com/fileman/users/Lazycat/dlls.html is a link to a screencapture app bu LazyCat.



Get Beta versions Here Get latest SciTE editor Here AutoIt 1-2-3 by Valuater - A great starting point.

Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0