evanevery Posted February 16, 2010 Posted February 16, 2010 I realize this should be pretty straight forward, but.... I need to be able to do a screen capture and save it to a file. Normally, the "_ScreenCapture_Capture" function would work just fine, except that it won't get Screen Images from the 3D screen (DirectX). However, the Windows "PrtScreen" function will get the associated screen image and put it into the clipboard just fine. So I've got the {PrintScreen} keypress being sent from a function just fine. I can open the Clipboard contents with Windows Paint and I see the data is there. So it appears that 'Send("{PrintScreen}")' does the job of getting my image loaded into the clipboard OK! I just can't seem to get the data in the clipboard saved into a file. I've tried all kinds of permutations of the following code, but it just seems I can not get the function to work. If someone could please tell me what I am doing wrong, it would surely be appreciated! (The following sample code runs from a hotkey function) #include <ClipBoard.au3> #Include <ScreenCapture.au3> HotKeySet("^s","ScreenCapture") While 1 Sleep(100) WEnd Func ScreenCapture() Send("{PRINTSCREEN}") _ClipBoard_Open(0) $hBitmap = _ClipBoard_GetData($CF_BITMAP) ; $HBitmap = _ScreenCapture_Capture("") ; This works for 2D screen! _ScreenCapture_SaveImage("ScreenCap.bmp", $hBitmap) _ClipBoard_Close() Exit EndFuncScreenCap.au3
evanevery Posted February 16, 2010 Author Posted February 16, 2010 Updated Info: The above code seems to work just fine on a Windows XP system but not on my Windows 7 (Ult-64) development platform. I've tried disabling my Anti-Virus but it appears to be something else. The "$hBitmap" handle in the code always comes back with a value of "0" on the Win7 machine. Its curious that the ScreenCapture_Capture function seems to work (but not for 3D screens). Anyone have any ideas or suggested "code-a-rounds"? Still Searching...
evanevery Posted February 17, 2010 Author Posted February 17, 2010 In doing some "@error" analysis, it appears that the "_MemGlobalAlloc" call in "_ClipBoard_GetData" is failing under Win7-64 (@error = -4). I can't find any reference to anything related in the forums. Maybe its a 64 bit thing, maybe it has something to do with additional Win7 security. Anyone have any ideas or thoughts on how I should continue?
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now