KaFu Posted January 6, 2013 Share Posted January 6, 2013 Example in still contained some AutoItObject leftovers, here's a more cleaned up version.expandcollapse popup#include <IE.au3> #include <WinAPI.au3> #include <ScreenCapture.au3> #include <WindowsConstants.au3> ; Runs fine with Beta 3.3.9.5+ If Int(StringReplace(@AutoItVersion, ".", "")) <= 3381 Then MsgBox(0, "Exit", "Requires AutoIt version > 3.3.8.1, try with Beta") Exit EndIf _WebCaptureTest("http://funk.eu", "Test1.png") Func _WebCaptureTest($Url, $ImageName) Local $hBmp = _WebCapture($Url, 1280) _ScreenCapture_SaveImage($ImageName, $hBmp, True) EndFunc ;==>_WebCaptureTest Func _WebCapture($Url, $WebWidth = 1024) Local $oIE = ObjCreate("Shell.Explorer.2") Local $hGUI = GUICreate("", $WebWidth, 768, -1, -1) Local $cObj = GUICtrlCreateObj($oIE, 0, 0, $WebWidth, 768) _IELoadWaitTimeout(20000) ; 20 sec _IENavigate($oIE, $Url) _IELoadWait($oIE) Local $oDocument = $oIE.document Local $oBody = $oIE.document.body Local $oHtml = $oIE.document.documentElement $oBody.scroll = "no" $oBody.style.borderStyle = "none" $oHtml.style.overflow = 'hidden' $oBody.style.overflow = 'hidden' Local $oIViewObject2 = ObjCreateInterface($oDocument, "{00000127-0000-0000-C000-000000000046}", "Draw hresult(dword;long;ptr;ptr;dword;dword;ptr;ptr;int;dword);") If @error Then Return SetError(1, 0, 0) Local $BodyWidth = $oBody.scrollWidth Local $BodyHeight = $oBody.scrollHeight Local $RootWidth = $oHtml.scrollWidth Local $RootHeight = $oHtml.scrollHeight Local $Width = $BodyWidth Local $Height = $RootHeight If $BodyHeight > $Height Then $Height = $BodyHeight $oIE.width = $Width $oIE.height = $Height Local $hDC = _WinAPI_GetDC(0) Local $hMemDC = _WinAPI_CreateCompatibleDC($hDC) Local $hBmp = _WinAPI_CreateCompatibleBitmap($hDC, $Width, $Height) _WinAPI_SelectObject($hMemDC, $hBmp) Local $sRECT = DllStructCreate($tagRECT) DllStructSetData($sRECT, "Top", 0) DllStructSetData($sRECT, "Left", 0) DllStructSetData($sRECT, "Right", $Width) DllStructSetData($sRECT, "Bottom", $Height) Local Const $DVASPECT_CONTENT = 1 $oIViewObject2.Draw($DVASPECT_CONTENT, -1, 0, 0, Number($hDC), Number($hMemDC), Number(DllStructGetPtr($sRECT)), 0, 0, 0) _WinAPI_DeleteDC($hMemDC) _WinAPI_ReleaseDC(0, $hDC) GUICtrlDelete($cObj) GUIDelete($hGUI) $oIViewObject2 = 0 $oIE = 0 Return $hBmp EndFunc ;==>_WebCapture trancexx and DinFuv 2 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...
trancexx Posted January 6, 2013 Share Posted January 6, 2013 (edited) ^^You can clean that up further more. Those Number() calls aren't necessary and mehod definition should be something like this: "Draw hresult(dword;long;ptr;ptr;handle;handle;struct*;struct*;bool;ulong_ptr);" Then you don't even need DllStructGetPtr(), you just pass struct for 7th param and you are sure method definition is correct for both x64 and x86. Edited January 6, 2013 by trancexx ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
KaFu Posted January 6, 2013 Share Posted January 6, 2013 (edited) Nice . How about the clean-up I perform at the end of the function? GUICtrlDelete($cObj) GUIDelete($hGUI) $oIViewObject2 = 0 $oIE = 0 When I set the GUI to visible I see it still exists after the function has finished, thus I assume a GUIDelete is appropriate. Is it advisable to delete the controls manually? And also the Objects, are those cleaned by the garbage collector? expandcollapse popup#include <IE.au3> #include <WinAPI.au3> #include <ScreenCapture.au3> #include <WindowsConstants.au3> ; Runs fine with Beta 3.3.9.5+ If Int(StringReplace(@AutoItVersion, ".", "")) <= 3381 Then MsgBox(0, "Exit", "Requires AutoIt version > 3.3.8.1, try with Beta") Exit EndIf _WebCaptureTest("http://funk.eu", "Test1.png") Func _WebCaptureTest($Url, $ImageName) Local $hBmp = _WebCapture($Url, 1280) _ScreenCapture_SaveImage($ImageName, $hBmp, True) EndFunc ;==>_WebCaptureTest Func _WebCapture($Url, $WebWidth = 1024) Local $oIE = ObjCreate("Shell.Explorer.2") Local $hGUI = GUICreate("", $WebWidth, 768, -1, -1) Local $cObj = GUICtrlCreateObj($oIE, 0, 0, $WebWidth, 768) _IELoadWaitTimeout(20000) ; 20 sec _IENavigate($oIE, $Url) _IELoadWait($oIE) Local $oDocument = $oIE.document Local $oBody = $oIE.document.body Local $oHtml = $oIE.document.documentElement $oBody.scroll = "no" $oBody.style.borderStyle = "none" $oHtml.style.overflow = 'hidden' $oBody.style.overflow = 'hidden' Local $oIViewObject2 = ObjCreateInterface($oDocument, "{00000127-0000-0000-C000-000000000046}", "Draw hresult(dword;long;ptr;ptr;handle;handle;struct*;struct*;bool;ulong_ptr);") If @error Then Return SetError(1, 0, 0) Local $BodyWidth = $oBody.scrollWidth Local $BodyHeight = $oBody.scrollHeight Local $RootWidth = $oHtml.scrollWidth Local $RootHeight = $oHtml.scrollHeight Local $Width = $BodyWidth Local $Height = $RootHeight If $BodyHeight > $Height Then $Height = $BodyHeight $oIE.width = $Width $oIE.height = $Height Local $hDC = _WinAPI_GetDC(0) Local $hMemDC = _WinAPI_CreateCompatibleDC($hDC) Local $hBmp = _WinAPI_CreateCompatibleBitmap($hDC, $Width, $Height) _WinAPI_SelectObject($hMemDC, $hBmp) Local $sRECT = DllStructCreate($tagRECT) DllStructSetData($sRECT, "Top", 0) DllStructSetData($sRECT, "Left", 0) DllStructSetData($sRECT, "Right", $Width) DllStructSetData($sRECT, "Bottom", $Height) $oIViewObject2.Draw(1, -1, 0, 0, $hDC, $hMemDC, $sRECT, 0, 0, 0) _WinAPI_DeleteDC($hMemDC) _WinAPI_ReleaseDC(0, $hDC) GUIDelete($hGUI) Return $hBmp EndFunc ;==>_WebCapture Edit: Added trancexx remarks from the next post, thanks a lot ... Edited January 6, 2013 by KaFu mLipok 1 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...
trancexx Posted January 6, 2013 Share Posted January 6, 2013 (edited) Nice . How about the clean-up I perform at the end of the function? GUICtrlDelete($cObj) GUIDelete($hGUI) $oIViewObject2 = 0 $oIE = 0 When I set the GUI to visible I see it still exists after the function has finished, thus I assume a GUIDelete is appropriate. Is it advisable to delete the controls manually? And also the Objects, are those cleaned by the garbage collector? Objecs are released for sure, yes. You don't have to reassign variables unless there is some super important order of destroying that needs to be followed. As for the GUI, I would expect that all the resources are released when the main window is destroyed. Edited January 6, 2013 by trancexx ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
Inververs Posted January 13, 2013 Share Posted January 13, 2013 I wonder if there is a working example for the ElementCapture function? Link to comment Share on other sites More sharing options...
OliverA Posted March 5, 2013 Share Posted March 5, 2013 (edited) KaFu i have two question about your script:Why don't you make directly:Func _WebCapture($Url, $ImageName, $WebWidth = 1024) ;the script Return _ScreenCapture_SaveImage($ImageName, $hBmp, True) ;Return $hBmpI don't want to use the BETA because it's a beta lol, which #include i need to "import" in the stable version? Or what i need to modify for use it? Edited March 5, 2013 by OliverA I'M QUIT FROM THIS FORUM! It was fun until it lasted, hope on my future way i can't find people that offend without any reason ( i was called lazy and parasitic, and everyone agreed...United we stand, divided we fall ) just for fun because don't have anything to do in the life, without knowing anything about the person who write, noone forced to post, noone forced to help.From the top of the from their very great superiority they not go down to my level, that people can not spread the knowledge but you have to learn by yourself. In what way? It's easy...just search on google For that people, wish you the best way, Oliver Astone Link to comment Share on other sites More sharing options...
KaFu Posted March 5, 2013 Share Posted March 5, 2013 Hi Oliver, I use "Return $hBmp" because not everyone might want to directly save the image to disk (e.g. add address overlay, timestamp, create a composite image). If you don't want to use the Beta, you have to use the example from the first post utilizing the AutoItObject UDF instead, your choice (the current Beta contains changes in the COM interface, which is a pre-requisite to use this without the AutoItObject UDF). Regards 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...
COBAY Posted August 28, 2013 Share Posted August 28, 2013 (edited) I wonder if I'm missing something here, the webcap works fine but the elementcap I cant seen to get working. I get an error from malkeys example Anyidea what Ive got going on here, I mean I can see that whatever $oIHTMLElementRender is, is isnt an object. But the code is over my head. IE9, IE10 fails DrawToDC call Local $tIID_IHTMLElementRender = _AutoItObject_CLSIDFromString("{3050F669-98B5-11CF-BB82-00AA00BDCE0B}") It would be not found the class id {3050F669-98B5-11CF-BB82-00AA00BDCE0B} not work on ie9, 10 Edited August 28, 2013 by COBAY Link to comment Share on other sites More sharing options...
mLipok Posted May 25, 2015 Share Posted May 25, 2015 Thank to all participant in this thread.For me this is the next step to make XML > XSL > HTML > PDF converter.mLipok btw.Works on IE 11.0.9600.17801and Au3.3.10.2 and Au3.3.13.20 Signature beginning:* Please remember: "AutoIt"..... * Wondering who uses AutoIt and what it can be used for ? * Forum Rules ** ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Code * for other useful stuff click the following button: Spoiler Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API * ErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 * My contribution to others projects or UDF based on others projects: * _sql.au3 UDF * POP3.au3 UDF * RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF * SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane * Useful links: * Forum Rules * Forum etiquette * Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * Wiki: * Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX IE Related: * How to use IE.au3 UDF with AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskScheduler * IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related: * How to get reference to PDF object embeded in IE * IE on Windows 11 * I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions * EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *I also encourage you to check awesome @trancexx code: * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuff * OnHungApp handler * Avoid "AutoIt Error" message box in unknown errors * HTML editor * winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/ "Homo sum; humani nil a me alienum puto" - Publius Terentius Afer"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming" , be and \\//_. Anticipating Errors : "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty." Signature last update: 2023-04-24 Link to comment Share on other sites More sharing options...
uncommon Posted July 19, 2018 Share Posted July 19, 2018 Not sure if anyone else ran into a problem but it seems like the _GDIPlus_EncodersGetCLSID does not seem to be working as expected. I Ran the example in the help file and got something like this. Codec GUID ............: {557CF400-1A04-11D3-9A73-0000F81EF32E} File format GUID ......: {B96B3CAB-0728-11D3-9D7B-0000F81EF32E} Codec name ............: 0x4275696C742D696E20424D5020436F64656300 Codec Dll file name ...: Codec file format .....: 0x424D5000 File name extensions ..: 0x2A2E424D503B2A2E4449423B2A2E524C4500 Mime type .............: 0x696D6167652F626D7000 Flags .................: 0x0000000000010007 Version ...............: 1 Signature count .......: 1 Signature size ........: 2 Signature pattern ptr .: 0x0317E982 Signature mask ptr ....: 0x0317E984 Parameter list size ...: 0 File name extensions should be more like (BMP, JPG, TIF, etc.) but now its in hex format. I had to change my __ScreenCapture_SaveImage function to know what $sCLSID to use and it worked after that. No problem can withstand the assault of sustained thinking.Voltaire _Array2HTMLTable(), _IEClassNameGetCollection(), _IEquerySelectorAll() Link to comment Share on other sites More sharing options...
UEZ Posted July 20, 2018 Share Posted July 20, 2018 17 hours ago, uncommon said: Not sure if anyone else ran into a problem but it seems like the _GDIPlus_EncodersGetCLSID does not seem to be working as expected. I Ran the example in the help file and got something like this. Codec GUID ............: {557CF400-1A04-11D3-9A73-0000F81EF32E} File format GUID ......: {B96B3CAB-0728-11D3-9D7B-0000F81EF32E} Codec name ............: 0x4275696C742D696E20424D5020436F64656300 Codec Dll file name ...: Codec file format .....: 0x424D5000 File name extensions ..: 0x2A2E424D503B2A2E4449423B2A2E524C4500 Mime type .............: 0x696D6167652F626D7000 Flags .................: 0x0000000000010007 Version ...............: 1 Signature count .......: 1 Signature size ........: 2 Signature pattern ptr .: 0x0317E982 Signature mask ptr ....: 0x0317E984 Parameter list size ...: 0 File name extensions should be more like (BMP, JPG, TIF, etc.) but now its in hex format. I had to change my __ScreenCapture_SaveImage function to know what $sCLSID to use and it worked after that. There is a "bug" in _WinAPI_WideCharToMultiByte() . Look here: 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...
Andyy Posted July 3, 2019 Share Posted July 3, 2019 I have taken the screenshot, but please help me to integrate with html report in selenium. it is not coming/ showing in html report Link to comment Share on other sites More sharing options...
Danp2 Posted July 3, 2019 Share Posted July 3, 2019 @Andyy You are using Autoit to take a screenshot of the webpage and then want to display it in an html report, correct? Why not take the screenshot directly from selenium? Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
KaFu Posted January 8, 2020 Share Posted January 8, 2020 (edited) Here's an update from my side: expandcollapse popup; https://www.autoitscript.com/forum/topic/124002-web-screenshot/?do=findComment&comment=1043557 #include <IE.au3> #include <WinAPI.au3> #include <ScreenCapture.au3> #include <WindowsConstants.au3> _WebCaptureTest("https://funk.eu", "funk.eu.png") ShellExecute(@ScriptDir & "\funk.eu.png") Func _WebCaptureTest($Url, $ImageName) Local $hBmp = _WebCapture($Url, 1280) _ScreenCapture_SaveImage($ImageName, $hBmp, True) EndFunc ;==>_WebCaptureTest Func _WebCapture($Url, $WebWidth = 1024) Local $oIE = ObjCreate("Shell.Explorer.2") Local $hGUI = GUICreate("", $WebWidth, 768, -1, -1) Local $cObj = GUICtrlCreateObj($oIE, 0, 0, $WebWidth, 768) _IELoadWaitTimeout(20000) ; 20 sec _IENavigate($oIE, $Url) _IELoadWait($oIE) Local $oDocument = $oIE.document Local $oBody = $oIE.document.body Local $oHtml = $oIE.document.documentElement $oBody.scroll = "no" $oBody.style.borderStyle = "none" $oHtml.style.overflow = 'hidden' $oBody.style.overflow = 'hidden' Local $oIViewObject2 = ObjCreateInterface($oDocument, "{00000127-0000-0000-C000-000000000046}", "Draw hresult(dword;long;ptr;ptr;handle;handle;struct*;struct*;bool;ulong_ptr);") If @error Then Return SetError(1, 0, 0) Local $BodyWidth = $oBody.scrollWidth Local $BodyHeight = $oBody.scrollHeight Local $RootWidth = $oHtml.scrollWidth Local $RootHeight = $oHtml.scrollHeight Local $Width = $BodyWidth Local $Height = $RootHeight If $BodyHeight > $Height Then $Height = $BodyHeight $oIE.width = $Width $oIE.height = $Height Local $hDC = _WinAPI_GetDC(0) Local $hMemDC = _WinAPI_CreateCompatibleDC($hDC) Local $hBmp = _WinAPI_CreateCompatibleBitmap($hDC, $Width, $Height) _WinAPI_SelectObject($hMemDC, $hBmp) Local $sRECT = DllStructCreate($tagRECT) DllStructSetData($sRECT, "Top", 0) DllStructSetData($sRECT, "Left", 0) DllStructSetData($sRECT, "Right", $Width) DllStructSetData($sRECT, "Bottom", $Height) $oIViewObject2.Draw(1, -1, 0, 0, $hDC, $hMemDC, $sRECT, 0, 0, 0) _WinAPI_DeleteDC($hMemDC) _WinAPI_ReleaseDC(0, $hDC) GUIDelete($hGUI) Return $hBmp EndFunc ;==>_WebCapture Edited January 8, 2020 by KaFu 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...
TheSaint Posted January 8, 2020 Share Posted January 8, 2020 1 hour ago, KaFu said: Here's an update from my side: Works well, thanks for sharing. I love how it captures the whole page, beyond what you see in the visible portion in your browser (without scrolling). I did a little edit at the start of your script, just to make testing for me a bit easier. #include <IE.au3> #include <WinAPI.au3> #include <ScreenCapture.au3> #include <WindowsConstants.au3> #include <Date.au3> Global $http, $image, $imgpth ;$http = "https://funk.eu" $http = "https://www.autoitscript.com/forum/topic/124002-web-screenshot/page/2/" $image = StringSplit($http, "/", 1) $image = $image[$image[0]] If $image = "" Then $image = StringReplace(_Now(), "/", "-") $image = StringReplace($image, ":", "_") EndIf $image = $image & ".png" $imgpth = @ScriptDir & "\" & $image _WebCaptureTest($http, $image) ShellExecute($imgpth) Exit I am also pondering adding a Splash in, due to the delay ... certainly on my PC. Make sure brain is in gear before opening mouth! Remember, what is not said, can be just as important as what is said. Spoiler What is the Secret Key? Life is like a Donut If I put effort into communication, I expect you to read properly & fully, or just not comment. Ignoring those who try to divert conversation with irrelevancies. If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it. I'm only big and bad, to those who have an over-active imagination. I may have the Artistic Liesense to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage) Link to comment Share on other sites More sharing options...
UEZ Posted January 8, 2020 Share Posted January 8, 2020 @KaFu you should release the bitmap handle when done in function _WebCaptureTest(): Func _WebCaptureTest($Url, $ImageName) Local $hBmp = _WebCapture($Url, 1280) _ScreenCapture_SaveImage($ImageName, $hBmp, True) _WinAPI_DeleteObject($hBmp) EndFunc ;==>_WebCaptureTest 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...
KaFu Posted January 8, 2020 Share Posted January 8, 2020 (edited) @UEZ The "True" in _ScreenCapture_SaveImage() will do just that 😉. Edited January 8, 2020 by KaFu 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 8, 2020 Share Posted January 8, 2020 6 minutes ago, KaFu said: @UEZ The "True" in _ScreenCapture_SaveImage() will do just that 😉. Well, it seems that I've overseen the 3rd parameter ($bFreeBmp) ... KaFu, TheSaint and Danp2 1 2 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...
TheSaint Posted January 8, 2020 Share Posted January 8, 2020 Pondering further, it seems to me that because the resulting image can have odd dimensions when it comes to height, that a split option based on user's screen height might be a nice additional option to have via a parameter... keeping the original image file as well of course. As an example, my capture of this page when I did it, was 1276 (w) x 14692 (h). That takes some zooming in to see detail .... depending on your viewer program. Of course, splitting to a series of separate image files could be the job of a companion program, but would be nice to be all-in-one. Maybe our resident graphic's expert UEZ could whip up something. I might even dabble myself ... if I get some time and feel like getting my head around the maths. Make sure brain is in gear before opening mouth! Remember, what is not said, can be just as important as what is said. Spoiler What is the Secret Key? Life is like a Donut If I put effort into communication, I expect you to read properly & fully, or just not comment. Ignoring those who try to divert conversation with irrelevancies. If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it. I'm only big and bad, to those who have an over-active imagination. I may have the Artistic Liesense to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage) Link to comment Share on other sites More sharing options...
KaFu Posted January 8, 2020 Share Posted January 8, 2020 Something like this? expandcollapse popup; https://www.autoitscript.com/forum/topic/124002-web-screenshot/?do=findComment&comment=1043557 #include <IE.au3> #include <WinAPI.au3> #include <ScreenCapture.au3> #include <WindowsConstants.au3> _WebCaptureTest("https://funk.eu", "funk.eu.png", 1000) ShellExecute(@ScriptDir & "\funk.eu.png") Func _WebCaptureTest($Url, $ImageName, $iMaxHeight = 0) Local $hBmp = _WebCapture($Url, 1280) _ScreenCapture_SaveImage($ImageName, $hBmp, False) If $iMaxHeight <> 0 Then _GDIPlus_Startup() Local $hImage = _GDIPlus_BitmapCreateFromHBITMAP($hBmp) Local $iX = _GDIPlus_ImageGetWidth($hImage) Local $iY = _GDIPlus_ImageGetHeight($hImage) Local $i_Pics = Ceiling($iY / $iMaxHeight) Local $i_Offset = 0, $hBmp_Clone, $iHeight_to_Clone = $iY For $i = 1 To $i_Pics If $iMaxHeight > $iHeight_to_Clone Then $iMaxHeight = $iHeight_to_Clone $hBmp_Clone = _GDIPlus_BitmapCloneArea($hImage, 0, 0 + $i_Offset, $iX, $iMaxHeight) _GDIPlus_ImageSaveToFile($hBmp_Clone, StringTrimRight($ImageName, 4) & "_" & $i & StringRight($ImageName, 4)) _GDIPlus_ImageDispose($hBmp_Clone) $iHeight_to_Clone -= $iMaxHeight $i_Offset += $iMaxHeight Next _GDIPlus_ImageDispose($hImage) _GDIPlus_Shutdown() EndIf _WinAPI_DeleteObject($hBmp) EndFunc ;==>_WebCaptureTest Func _WebCapture($Url, $WebWidth = 1024) Local $oIE = ObjCreate("Shell.Explorer.2") Local $hGUI = GUICreate("", $WebWidth, 768, -1, -1) Local $cObj = GUICtrlCreateObj($oIE, 0, 0, $WebWidth, 768) _IELoadWaitTimeout(20000) ; 20 sec _IENavigate($oIE, $Url) _IELoadWait($oIE) Local $oDocument = $oIE.document Local $oBody = $oIE.document.body Local $oHtml = $oIE.document.documentElement $oBody.scroll = "no" $oBody.style.borderStyle = "none" $oHtml.style.overflow = 'hidden' $oBody.style.overflow = 'hidden' Local $oIViewObject2 = ObjCreateInterface($oDocument, "{00000127-0000-0000-C000-000000000046}", "Draw hresult(dword;long;ptr;ptr;handle;handle;struct*;struct*;bool;ulong_ptr);") If @error Then Return SetError(1, 0, 0) Local $BodyWidth = $oBody.scrollWidth Local $BodyHeight = $oBody.scrollHeight Local $RootWidth = $oHtml.scrollWidth Local $RootHeight = $oHtml.scrollHeight Local $Width = $BodyWidth Local $Height = $RootHeight If $BodyHeight > $Height Then $Height = $BodyHeight $oIE.width = $Width $oIE.height = $Height Local $hDC = _WinAPI_GetDC(0) Local $hMemDC = _WinAPI_CreateCompatibleDC($hDC) Local $hBmp = _WinAPI_CreateCompatibleBitmap($hDC, $Width, $Height) _WinAPI_SelectObject($hMemDC, $hBmp) Local $sRECT = DllStructCreate($tagRECT) DllStructSetData($sRECT, "Top", 0) DllStructSetData($sRECT, "Left", 0) DllStructSetData($sRECT, "Right", $Width) DllStructSetData($sRECT, "Bottom", $Height) $oIViewObject2.Draw(1, -1, 0, 0, $hDC, $hMemDC, $sRECT, 0, 0, 0) _WinAPI_DeleteDC($hMemDC) _WinAPI_ReleaseDC(0, $hDC) GUIDelete($hGUI) Return $hBmp EndFunc ;==>_WebCapture TheSaint and UEZ 1 1 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...
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