damael Posted November 11, 2009 Share Posted November 11, 2009 Hi First sorry for my bad english. I always get this error when i run my script over a longer time. _winapi_createCompatibleBitmap: Not enough storage to process the command The only place where this command is executed is in _ScreenCapture_Capture. I am doing a OCR with OhSeeAre.exe and for this i must do the screencapture. I already tried to correct the _ScreenCapture_Capture with the following but, the error still happens. It comes after 30 minutes to one and a half hour. expandcollapse popupFunc _ScreenCapture_Capture($sFileName = "", $iLeft = 0, $iTop = 0, $iRight = -1, $iBottom = -1, $fCursor = True) Local $iH, $iW, $hWnd, $hDDC, $hCDC, $hBMP, $aCursor, $aIcon, $hIcon If $iRight = -1 Then $iRight = _WinAPI_GetSystemMetrics($__SCREENCAPTURECONSTANT_SM_CXSCREEN) If $iBottom = -1 Then $iBottom = _WinAPI_GetSystemMetrics($__SCREENCAPTURECONSTANT_SM_CYSCREEN) If $iRight < $iLeft Then Return SetError(-1, 0, 0) If $iBottom < $iTop Then Return SetError(-2, 0, 0) $iW = $iRight - $iLeft $iH = $iBottom - $iTop $hWnd = _WinAPI_GetDesktopWindow() $hDDC = _WinAPI_GetDC($hWnd) $hCDC = _WinAPI_CreateCompatibleDC($hDDC) $hBMP = _WinAPI_CreateCompatibleBitmap($hDDC, $iW, $iH) _WinAPI_SelectObject($hCDC, $hBMP) _WinAPI_BitBlt($hCDC, 0, 0, $iW, $iH, $hDDC, $iLeft, $iTop, $__SCREENCAPTURECONSTANT_SRCCOPY) If $fCursor Then $aCursor = _WinAPI_GetCursorInfo() If $aCursor[1] Then $hIcon = _WinAPI_CopyIcon($aCursor[2]) $aIcon = _WinAPI_GetIconInfo($hIcon) _WinAPI_DrawIcon($hCDC, $aCursor[3] - $aIcon[2] - $iLeft, $aCursor[4] - $aIcon[3] - $iTop, $hIcon) _WinAPI_DestroyIcon($hIcon) _WinAPI_DeleteObject($aIcon[4]); <- THIS! _WinAPI_DeleteObject($aIcon[5]); <- THIS! _WinAPI_DeleteObject($aIcon) EndIf EndIf _WinAPI_ReleaseDC($hWnd, $hDDC) _WinAPI_DeleteDC($hCDC) If $sFileName = "" Then Return $hBMP _ScreenCapture_SaveImage($sFileName, $hBMP) _WinAPI_DeleteObject($hBMP) EndFunc ;==>_ScreenCapture_Capture From http://www.autoitscript.com/forum/index.php?showtopic=97843 and http://www.autoitscript.com/forum/index.php?showtopic=89542&st=40 I am testing a loop where it only does screencapture. It run for 30 minutes from the old code then came the error. Right now i am testing the new code... Lets see what happens Please help, this bug is really annoying. Thx bb Link to comment Share on other sites More sharing options...
damael Posted November 11, 2009 Author Share Posted November 11, 2009 It ran for more than a half an hour now and the error didn't happen... I leave it running. That is what i don't understand. I did test it yesterday and the error also didn't happen, but when i execute the hole script it does happen always after one hour -.- The only place where this _winapi_createcompatiblebitmap is executed is in the screencapture. Does anyone have an idea? Link to comment Share on other sites More sharing options...
Yashied Posted November 11, 2009 Share Posted November 11, 2009 #1040 My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More... Link to comment Share on other sites More sharing options...
damael Posted November 11, 2009 Author Share Posted November 11, 2009 Thank you Im trying this code. Is it working? Link to comment Share on other sites More sharing options...
damael Posted November 11, 2009 Author Share Posted November 11, 2009 After 15 Minutes Error: _WinAPI_CreateCompatibleBitmap: Not enough storage is available to process this command. Is the error not from screencapture? Is this not fixed at the time? What to do then is there an alternative to screencapture that does the same without the error? pls help Link to comment Share on other sites More sharing options...
jvanegmond Posted November 11, 2009 Share Posted November 11, 2009 Calm down, young grasshopper. To learn, you must be patient. One person can not know everything, sometimes you must wait for someone else to answer your questions. The Trac issue has a nice example that displays how many GDI objects you currently have. Why not try it with your code and determine if you have a memory leak for yourself? github.com/jvanegmond Link to comment Share on other sites More sharing options...
whim Posted November 11, 2009 Share Posted November 11, 2009 ...nice example that displays how many GDI objects you currently have...task manager also provides this info (after selecting in View -> Select Columns)whim Link to comment Share on other sites More sharing options...
damael Posted November 11, 2009 Author Share Posted November 11, 2009 Ok. I have done it with my main loop correct? It always showed 39, also when the error happened. Then i tried the loop alone, as written in the ticket, it did show always 31. Link to comment Share on other sites More sharing options...
AndyG Posted November 11, 2009 Share Posted November 11, 2009 Hi, this could have something to do with a leak problem i had with _GDIPlus_BitmapLockBits() which is used by the screencapture-Functions. The solution was changingDllCall($ghGDIPDll, "int", "GdipBitmapUnlockBits", "hwnd", $hBitmap, "int*", DllStructGetPtr($tBitmapData))to DllCall($ghGDIPDll, "int", "GdipBitmapUnlockBits", "hwnd", $hBitmap, "ptr", DllStructGetPtr($tBitmapData))in the screencapture.au3 Andy Link to comment Share on other sites More sharing options...
damael Posted November 11, 2009 Author Share Posted November 11, 2009 Hi Andy Thank You. Cannot find GdipBitmapUnlockBits iny screencapture would you post me yours? Link to comment Share on other sites More sharing options...
AndyG Posted November 11, 2009 Share Posted November 11, 2009 sorry, my fault.... change the mentioned line above in the GDIplus.au3 to Func _GDIPlus_BitmapUnlockBits($hBitmap, $tBitmapData) Local $aResult $aResult = DllCall($ghGDIPDll, "int", "GdipBitmapUnlockBits", "hwnd", $hBitmap, "ptr", DllStructGetPtr($tBitmapData)) If @error Then Return SetError(@error, @extended, False) Return SetError($aResult[0], 0, $aResult[0] = 0) EndFunc ;==>_GDIPlus_BitmapUnlockBits Link to comment Share on other sites More sharing options...
damael Posted November 11, 2009 Author Share Posted November 11, 2009 (edited) Ok i tested it after 45 Minutes came the error. GDI Objects = 39 I read somewhere that the problem is createCompatibleBitmap itself and instead there should be used createDIBSection. Because the createCompatibleBitmap saves to a storage which is limited, like a root partition. But i dont know where i read this. Is there any alternative to _screencapture_capture? Or is there a screencapture that does use the createDIBSection? Edited November 11, 2009 by damael Link to comment Share on other sites More sharing options...
damael Posted November 11, 2009 Author Share Posted November 11, 2009 or i do a batch that checks if the app is working but its the last possibility Link to comment Share on other sites More sharing options...
Yashied Posted November 11, 2009 Share Posted November 11, 2009 What are you talking about? There written black on white (yellow):The returned bitmap handles from _WinAPI_GetIconInfo() are not deleted.AndFixed in version: 3.3.1.2Just use the AutoIt 3.3.1.2 and above. My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More... Link to comment Share on other sites More sharing options...
andr2510 Posted May 8, 2020 Share Posted May 8, 2020 On 11/12/2009 at 2:39 AM, Yashied said: What are you talking about? There written black on white (yellow): And Just use the AutoIt 3.3.1.2 and above. No. 3.3.14.5 Don't work/ Memory leaks on _ScreenCapture_Capture() Link to comment Share on other sites More sharing options...
KaFu Posted May 8, 2020 Share Posted May 8, 2020 If a handle is returned, it must be released using _WinAPI_DeleteObject(). OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2022-Nov-26) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Feb-16) HMW - Hide my Windows (2018-Sep-16) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2023-Jun-03) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
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