webpower Posted January 17, 2013 Share Posted January 17, 2013 It creates no Screenshot, but I don't know why.. Here are the result expandcollapse popup>Running:(3.3.8.1):C:\Program Files\AutoIt3\autoit3.exe "C:\daten\autoit_dev\sc.au3" 1680x1050 0 1 0 0 0 1 0x00000000 1 $sFileName: C:\daten\autoit_dev\test.png 1 0 False Fileexists: 0 1680x1050 0 1 0 0 0 1 0x00000000 1 $sFileName: C:\daten\autoit_dev\test.bmp 1 0 False Fileexists: 0 1680x1050 0 1 0 0 0 1 0x00000000 1 $sFileName: C:\daten\autoit_dev\test.jpg 1 0 False Fileexists: 0 1680x1050 0 1 0 0 0 1 0x00000000 1 $sFileName: C:\daten\autoit_dev\test.tif 1 0 False Fileexists: 0 +>12:22:49 AutoIT3.exe ended.rc:0 >Exit code: 0 Time: 1.825 I think the real Problem is on my XP Machine.. Link to comment Share on other sites More sharing options...
KaFu Posted January 17, 2013 Share Posted January 17, 2013 I think so too, there seems to be something messed up with your install... next test: expandcollapse popup#include <ScreenCapture.au3> _ScreenCapture(@ScriptDir & "\test.png") _ScreenCapture(@ScriptDir & "\test.bmp") _ScreenCapture(@ScriptDir & "\test.jpg") _ScreenCapture(@ScriptDir & "\test.tif") Func _ScreenCapture($sFileName) Local $iRet = _ScreenCapture_Capture_Ex($sFileName) ConsoleWrite(@error & @TAB & @extended & @TAB & $iRet & @CRLF) Local $iFileExists = FileExists($sFileName) ConsoleWrite("Fileexists: " & $iFileExists & @CRLF) If $iFileExists Then _GDIPlus_Startup() $hImage = _GDIPlus_ImageLoadFromFile($sFileName) ConsoleWrite(_GDIPlus_ImageGetWidth($hImage) & "x" & _GDIPlus_ImageGetHeight($hImage) & @CRLF) _GDIPlus_ImageDispose($hImage) _GDIPlus_Shutdown() EndIf EndFunc ;==>_ScreenCapture Func _ScreenCapture_Capture_Ex($sFileName = "", $iLeft = 0, $iTop = 0, $iRight = -1, $iBottom = -1, $fCursor = True) 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) Local $iW = ($iRight - $iLeft) ; + 1 ; Bug !!! Local $iH = ($iBottom - $iTop) ; + 1 ; Bug !!! ConsoleWrite($iW & "x" & $iH & @CRLF) Local $hWnd = _WinAPI_GetDesktopWindow() ConsoleWrite(@error & @TAB & IsHWnd($hWnd) & @CRLF) Local $hDDC = _WinAPI_GetDC($hWnd) ConsoleWrite(@error & @CRLF) Local $hCDC = _WinAPI_CreateCompatibleDC($hDDC) ConsoleWrite(@error & @CRLF) Local $hBMP = _WinAPI_CreateCompatibleBitmap($hDDC, $iW, $iH) ConsoleWrite(@error & @TAB & IsPtr($hBMP) & @tab & $hBMP & @CRLF) ConsoleWrite(_WinAPI_SelectObject($hCDC, $hBMP) & @CRLF) ConsoleWrite(_WinAPI_GetLastError() & @tab & _WinAPI_GetLastErrorMessage() & @crlf) ConsoleWrite(_WinAPI_BitBlt($hCDC, 0, 0, $iW, $iH, $hDDC, $iLeft, $iTop, $__SCREENCAPTURECONSTANT_SRCCOPY) & @CRLF) If $fCursor Then Local $aCursor = _WinAPI_GetCursorInfo() If $aCursor[1] Then Local $hIcon = _WinAPI_CopyIcon($aCursor[2]) Local $aIcon = _WinAPI_GetIconInfo($hIcon) _WinAPI_DeleteObject($aIcon[4]) ; delete bitmap mask return by _WinAPI_GetIconInfo() If $aIcon[5] <> 0 Then _WinAPI_DeleteObject($aIcon[5]); delete bitmap hbmColor return by _WinAPI_GetIconInfo() _WinAPI_DrawIcon($hCDC, $aCursor[3] - $aIcon[2] - $iLeft, $aCursor[4] - $aIcon[3] - $iTop, $hIcon) _WinAPI_DestroyIcon($hIcon) EndIf EndIf _WinAPI_ReleaseDC($hWnd, $hDDC) _WinAPI_DeleteDC($hCDC) ConsoleWrite("$sFileName: " & $sFileName & @CRLF) If $sFileName = "" Then Return $hBMP Local $ret = _ScreenCapture_SaveImage($sFileName, $hBMP, True) Return SetError(@error, @extended, $ret) EndFunc ;==>_ScreenCapture_Capture_Ex OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
webpower Posted January 17, 2013 Share Posted January 17, 2013 (edited) This are the Result of the XP Machine ( maybe some Words in German ) expandcollapse popup>Running:(3.3.8.1):C:\Program Files\AutoIt3\autoit3.exe "C:\daten\autoit_dev\sc.au3" 1680x1050 0 1 0 0 0 1 0x00000000 0x00000000 8 Für diesen Befehl ist nicht genügend Speicher verfügbar. 1 $sFileName: C:\daten\autoit_dev\test.png 1 0 False Fileexists: 0 1680x1050 0 1 0 0 0 1 0x00000000 0x00000000 8 Für diesen Befehl ist nicht genügend Speicher verfügbar. 1 $sFileName: C:\daten\autoit_dev\test.bmp 1 0 False Fileexists: 0 1680x1050 0 1 0 0 0 1 0x00000000 0x00000000 8 Für diesen Befehl ist nicht genügend Speicher verfügbar. 1 $sFileName: C:\daten\autoit_dev\test.jpg 1 0 False Fileexists: 0 1680x1050 0 1 0 0 0 1 0x00000000 0x00000000 8 Für diesen Befehl ist nicht genügend Speicher verfügbar. 1 $sFileName: C:\daten\autoit_dev\test.tif 1 0 False Fileexists: 0 +>14:12:29 AutoIT3.exe ended.rc:0 >Exit code: 0 Time: 2.275 "Für diesen Befehl ist nicht genügend Speicher verfügbar." meens this Harddisk Space or Memory Space? On the Win 7 Machine "Der Vorgang wurde erfolgreich beendet." expandcollapse popup1680x1050 0 1 0 0 0 1 0xFC050806 0x0185000F 0 Der Vorgang wurde erfolgreich beendet. 1 $sFileName: C:\temp\test.png 0 0 True Fileexists: 1 1680x1050 1680x1050 0 1 0 0 0 1 0x42050AE6 0x0185000F 0 Der Vorgang wurde erfolgreich beendet. 1 $sFileName: C:\temp\test.bmp 0 0 True Fileexists: 1 1680x1050 1680x1050 0 1 0 0 0 1 0xAC050806 0x0185000F 0 Der Vorgang wurde erfolgreich beendet. 1 $sFileName: C:\temp\test.jpg 0 0 True Fileexists: 1 1680x1050 1680x1050 0 1 0 0 0 1 0x40050B4A 0x0185000F 0 Der Vorgang wurde erfolgreich beendet. 1 $sFileName: C:\temp\test.tif 0 0 True Fileexists: 1 1680x1050 >Exit code: 0 Time: 1.332 Edited January 17, 2013 by webpower Link to comment Share on other sites More sharing options...
KaFu Posted January 17, 2013 Share Posted January 17, 2013 I think we got a winner here: ERROR_NOT_ENOUGH_MEMORY 0x8 Not enough storage is available to process this command. How much RAM do you have in your XP box? Maybe it works with a call to _WinAPI_EmptyWorkingSet - Removes as many pages as possible from the working set of the specified process. expandcollapse popup#include <ScreenCapture.au3> _ScreenCapture(@ScriptDir & "\test.png") _ScreenCapture(@ScriptDir & "\test.bmp") _ScreenCapture(@ScriptDir & "\test.jpg") _ScreenCapture(@ScriptDir & "\test.tif") Func _ScreenCapture($sFileName) Local $iRet = _ScreenCapture_Capture_Ex($sFileName) ConsoleWrite(@error & @TAB & @extended & @TAB & $iRet & @CRLF) Local $iFileExists = FileExists($sFileName) ConsoleWrite("Fileexists: " & $iFileExists & @CRLF) If $iFileExists Then _GDIPlus_Startup() $hImage = _GDIPlus_ImageLoadFromFile($sFileName) ConsoleWrite(_GDIPlus_ImageGetWidth($hImage) & "x" & _GDIPlus_ImageGetHeight($hImage) & @CRLF) _GDIPlus_ImageDispose($hImage) _GDIPlus_Shutdown() EndIf EndFunc ;==>_ScreenCapture Func _ScreenCapture_Capture_Ex($sFileName = "", $iLeft = 0, $iTop = 0, $iRight = -1, $iBottom = -1, $fCursor = True) 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) Local $iW = ($iRight - $iLeft) ; + 1 ; Bug !!! Local $iH = ($iBottom - $iTop) ; + 1 ; Bug !!! ConsoleWrite($iW & "x" & $iH & @CRLF) Local $hWnd = _WinAPI_GetDesktopWindow() ConsoleWrite(@error & @TAB & IsHWnd($hWnd) & @CRLF) Local $hDDC = _WinAPI_GetDC($hWnd) ConsoleWrite(@error & @CRLF) Local $hCDC = _WinAPI_CreateCompatibleDC($hDDC) ConsoleWrite(@error & @CRLF) Local $hBMP = _WinAPI_CreateCompatibleBitmap($hDDC, $iW, $iH) ConsoleWrite(@error & @TAB & IsPtr($hBMP) & @TAB & $hBMP & @CRLF) _WinAPI_EmptyWorkingSet() ; Removes as many pages as possible from the working set of the specified process. ConsoleWrite(_WinAPI_SelectObject($hCDC, $hBMP) & @CRLF) ConsoleWrite(_WinAPI_GetLastError() & @TAB & _WinAPI_GetLastErrorMessage() & @CRLF) ConsoleWrite(_WinAPI_BitBlt($hCDC, 0, 0, $iW, $iH, $hDDC, $iLeft, $iTop, $__SCREENCAPTURECONSTANT_SRCCOPY) & @CRLF) If $fCursor Then Local $aCursor = _WinAPI_GetCursorInfo() If $aCursor[1] Then Local $hIcon = _WinAPI_CopyIcon($aCursor[2]) Local $aIcon = _WinAPI_GetIconInfo($hIcon) _WinAPI_DeleteObject($aIcon[4]) ; delete bitmap mask return by _WinAPI_GetIconInfo() If $aIcon[5] <> 0 Then _WinAPI_DeleteObject($aIcon[5]); delete bitmap hbmColor return by _WinAPI_GetIconInfo() _WinAPI_DrawIcon($hCDC, $aCursor[3] - $aIcon[2] - $iLeft, $aCursor[4] - $aIcon[3] - $iTop, $hIcon) _WinAPI_DestroyIcon($hIcon) EndIf EndIf _WinAPI_ReleaseDC($hWnd, $hDDC) _WinAPI_DeleteDC($hCDC) ConsoleWrite("$sFileName: " & $sFileName & @CRLF) If $sFileName = "" Then Return $hBMP Local $ret = _ScreenCapture_SaveImage($sFileName, $hBMP, True) Return SetError(@error, @extended, $ret) EndFunc ;==>_ScreenCapture_Capture_Ex Func _WinAPI_EmptyWorkingSet($PID = 0) If Not $PID Then $PID = @AutoItPID EndIf Local $hProcess = DllCall('kernel32.dll', 'ptr', 'OpenProcess', 'dword', __Iif(__WINVER() < 0x0600, 0x00000500, 0x00001100), 'int', 0, 'dword', $PID) If (@error) Or (Not $hProcess[0]) Then Return SetError(1, 0, 0) EndIf Local $ret = DllCall(@SystemDir & '\psapi.dll', 'int', 'EmptyWorkingSet', 'ptr', $hProcess[0]) If (@error) Or (Not $ret[0]) Then $ret = 0 EndIf _WinAPI_CloseHandle($hProcess[0]) If Not IsArray($ret) Then Return SetError(1, 0, 0) EndIf Return 1 EndFunc ;==>_WinAPI_EmptyWorkingSet Func __WINVER() Local $tOSVI = DllStructCreate('dword;dword;dword;dword;dword;wchar[128]') DllStructSetData($tOSVI, 1, DllStructGetSize($tOSVI)) Local $Ret = DllCall('kernel32.dll', 'int', 'GetVersionExW', 'ptr', DllStructGetPtr($tOSVI)) If (@error) Or (Not $Ret[0]) Then Return SetError(1, 0, 0) EndIf Return BitOR(BitShift(DllStructGetData($tOSVI, 2), -8), DllStructGetData($tOSVI, 3)) EndFunc ;==>__WINVER Func __Iif($fTest, $iTrue, $iFalse) If $fTest Then Return $iTrue Else Return $iFalse EndIf EndFunc ;==>__Iif OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
UEZ Posted January 17, 2013 Share Posted January 17, 2013 What is the uptime of your WinXP machine? Maybe: "Reboot tut gut"! Br, UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
webpower Posted January 18, 2013 Share Posted January 18, 2013 I've 4GB RAM and 1GB available. Maybe UEZ have right, my Box is up for 10 Days. KaFu, thank you for your script, but it also does'nt work. On the weekend I will reboot the XP Machine, and try it again on Monday. Thank you so much for assistance. Link to comment Share on other sites More sharing options...
webpower Posted January 18, 2013 Share Posted January 18, 2013 After I closed some unused Programs it works on my XP Machine too.!! Link to comment Share on other sites More sharing options...
basmaster Posted May 9, 2013 Share Posted May 9, 2013 Works great! Now if only someone could do the same for autoit's built in "pixel" functions. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 9, 2013 Moderators Share Posted May 9, 2013 basmaster,Welcome to the AutoIt forum. I hope you realise that the ScreenCapture library is a UDF, that is to say coded in AutoIt - whereas the Pixel* functions are native and so written in C++. You are not going to get them much faster than they are already - and they have already been rewritten to make them faster (look in the Help file to confirm this). So I fear that your wishes are unlikely to become reality. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
basmaster Posted May 9, 2013 Share Posted May 9, 2013 Thanks. Speed isn't so much my issue with the native "pixel" function (however they are dreadfully slow with windows aero enabled). As Pinault stated, "_ScreenCapture_Capture is unable to take a screenshot of layered windows (drawn by the graphic card)." and I believe the same is true for the "pixel" functions unless aero is enabled it seems. This might be the wrong topic to ask about this but is there a workaround for this? Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 9, 2013 Moderators Share Posted May 9, 2013 (edited) basmaster,The "Aero" problem well known and apparently unlikely to be solved any time soon. If you want to ask about workarounds I suggest opening a new topic - we prefer you to do that if, as in this case, the question is not really related to the original. M23Edit: Just to be clear, the current "Aero" solution is to turn it off - I meant that there is unlikely to be a rewrite to get a speedy response with Aero enabled. Edited May 9, 2013 by Melba23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
BrewManNH Posted May 10, 2013 Share Posted May 10, 2013 BTW, I don't believe any function that starts with Pixel takes screenshots. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator 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