ingosa Posted October 29, 2020 Posted October 29, 2020 (edited) Good day you all. I am new to autoit and are searching fore day's to find How you get a Taken image area screenshot into a memory string. Like this: $FileName = "0xFFD8FFE000104A46494600010101006000600000FFE1001645786966000049492A0008000000000000000000FFDB004300080606070605080707070909080A" I found it in a tutorial on how to get it From a memory string back into a image :S In short, my idea is to take a screenshot of a area with a selection box and than Not save it as a image file, but as a string like that above in a ini file with all the info of the taken screenshot. Like size, taken date, and the reason of taking it. The art thing is that i can only find how to use it to make the image, But not store it in a string like that.. I hope some one can help me with this. Best Regards Edited October 29, 2020 by ingosa
Musashi Posted October 29, 2020 Posted October 29, 2020 58 minutes ago, ingosa said: I hope some one can help me with this. As usual @UEZ has the answer : expandcollapse popup;Coded by UEZ 2013 -> This program requires AutoIt version 3.3.9.21 or higher! #include <Screencapture.au3> #include <Memory.au3> _GDIPlus_Startup() Global $hHBitmap = _ScreenCapture_Capture("", 0, 0, 100, 100) Global $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hHBitmap) Global $bImage = _GDIPlus_StreamImage2BinaryString($hBitmap) ConsoleWrite("Error: " & @error & @LF) MsgBox(0, "Binary", $bImage) _GDIPlus_BitmapDispose($hBitmap) _WinAPI_DeleteObject($hHBitmap) _GDIPlus_Shutdown() Func _GDIPlus_StreamImage2BinaryString($hBitmap, $sFormat = "JPG", $iQuality = 80, $bSave = False, $sFilename = "Converted.jpg") ;coded by UEZ 2013 build 2013-09-14 Local $sImgCLSID, $tGUID, $tParams Switch $sFormat Case "JPG" $sImgCLSID = _GDIPlus_EncodersGetCLSID($sFormat) $tGUID = _WinAPI_GUIDFromString($sImgCLSID) Local $tData = DllStructCreate("int Quality") DllStructSetData($tData, "Quality", $iQuality) ;quality 0-100 Local $pData = DllStructGetPtr($tData) $tParams = _GDIPlus_ParamInit(1) _GDIPlus_ParamAdd($tParams, $GDIP_EPGQUALITY, 1, $GDIP_EPTLONG, $pData) Case "PNG", "BMP", "GIF", "TIF" $sImgCLSID = _GDIPlus_EncodersGetCLSID($sFormat) $tGUID = _WinAPI_GUIDFromString($sImgCLSID) Case Else Return SetError(1, 0, 0) EndSwitch Local $hStream = _WinAPI_CreateStreamOnHGlobal() ;http://msdn.microsoft.com/en-us/library/ms864401.aspx If @error Then Return SetError(2, 0, 0) _GDIPlus_ImageSaveToStream($hBitmap, $hStream, DllStructGetPtr($tGUID), DllStructGetPtr($tParams)) If @error Then Return SetError(3, 0, 0) _GDIPlus_BitmapDispose($hBitmap) Local $hMemory = _WinAPI_GetHGlobalFromStream($hStream) ;http://msdn.microsoft.com/en-us/library/aa911736.aspx If @error Then Return SetError(4, 0, 0) Local $iMemSize = _MemGlobalSize($hMemory) If Not $iMemSize Then Return SetError(5, 0, 0) Local $pMem = _MemGlobalLock($hMemory) $tData = DllStructCreate("byte[" & $iMemSize & "]", $pMem) Local $bData = DllStructGetData($tData, 1) _WinAPI_ReleaseStream($hStream) ;http://msdn.microsoft.com/en-u…op/ms221473(v=vs.85).aspx _MemGlobalFree($hMemory) If $bSave Then Local $hFile = FileOpen($sFilename, 18) If @error Then Return SetError(6, 0, $bData) FileWrite($hFile, $bData) FileClose($hFile) EndIf Return $bData EndFunc ;==>_GDIPlus_StreamImage2BinaryString "In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."
Nine Posted October 29, 2020 Posted October 29, 2020 I think this is what you are looking for : #include <GDIPlus.au3> #include <ScreenCapture.au3> _GDIPlus_Startup() Local $hBitMap = _ScreenCapture_Capture ("", 50, 50, 100, 100, False) Local $hImage = _GDIPlus_BitmapCreateFromHBITMAP ($hBitMap) _WinAPI_DeleteObject($hBitMap) Local $BitmapData = _GDIPlus_BitmapLockBits($hImage, 0, 0, 51, 51, $GDIP_ILMREAD, $GDIP_PXF32ARGB) Local $Scan = DllStructGetData($BitmapData, "Scan0") Local $bData = DllStructCreate("byte string [" & 51 * 51 * 4 & "]",$Scan) ConsoleWrite ($bData.string & @CRLF) _GDIPlus_BitmapUnlockBits($hImage, $BitmapData) _GDIPlus_ImageDispose($hImage) _GDIPlus_Shutdown() “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy
ingosa Posted October 29, 2020 Author Posted October 29, 2020 20 minutes ago, Nine said: I think this is what you are looking for : #include <GDIPlus.au3> #include <ScreenCapture.au3> _GDIPlus_Startup() Local $hBitMap = _ScreenCapture_Capture ("", 50, 50, 100, 100, False) Local $hImage = _GDIPlus_BitmapCreateFromHBITMAP ($hBitMap) _WinAPI_DeleteObject($hBitMap) Local $BitmapData = _GDIPlus_BitmapLockBits($hImage, 0, 0, 51, 51, $GDIP_ILMREAD, $GDIP_PXF32ARGB) Local $Scan = DllStructGetData($BitmapData, "Scan0") Local $bData = DllStructCreate("byte string [" & 51 * 51 * 4 & "]",$Scan) ConsoleWrite ($bData.string & @CRLF) _GDIPlus_BitmapUnlockBits($hImage, $BitmapData) _GDIPlus_ImageDispose($hImage) _GDIPlus_Shutdown() Thanks a lot, that was it yes How can i mark as solved?
Nine Posted October 29, 2020 Posted October 29, 2020 1 minute ago, ingosa said: How can i mark as solved? You can change the title and add [SOLVED] at the beginning. Can I ask you to provide the code you have to recreate the image ? It may help someone who is looking for it in the future. Thanks. “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy
Moderators Melba23 Posted October 29, 2020 Moderators Posted October 29, 2020 Moved to the appropriate forum, as the Developer General Discussion forum very clearly states: Quote General development and scripting discussions. Do not create AutoIt-related topics here, use the AutoIt General Help and Support or AutoIt Technical Discussion forums. Moderation Team 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
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