Jump to content
Sign in to follow this  

Screen Capture

Recommended Posts

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)

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

; 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

; select bitmap to device context

; copy picture information from the screen to device context in memory

; break for doing anything on screen

; 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,3, $hbmp)
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!!!


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.

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...