<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Серый форум &mdash; AHK: Сохранение скриншота из буфера обмена Win11]]></title>
		<link>https://forum.script-coding.com/viewtopic.php?id=17233</link>
		<atom:link href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=17233&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[Недавние сообщения в теме «AHK: Сохранение скриншота из буфера обмена Win11».]]></description>
		<lastBuildDate>Thu, 07 Jul 2022 15:37:37 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: AHK: Сохранение скриншота из буфера обмена Win11]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=153810#p153810</link>
			<description><![CDATA[<p>Нашел способ с gdiplus библиотекой:</p><div class="codebox"><pre><code>
setbatchlines -1
DllCall(&quot;LoadLibrary&quot;, &quot;str&quot;, &quot;gdiplus&quot;)
VarSetCapacity(si, A_PtrSize = 8 ? 24 : 16, 0) ; sizeof(GdiplusStartupInput) = 16, 24
NumPut(0x1, si, &quot;uint&quot;)
DllCall(&quot;gdiplus\GdiplusStartup&quot;, &quot;ptr*&quot;, pToken:=0, &quot;ptr&quot;, &amp;si, &quot;ptr&quot;, 0)
extension := &quot;jpg&quot;
DllCall(&quot;gdiplus\GdipGetImageEncodersSize&quot;, &quot;uint*&quot;, count:=0, &quot;uint*&quot;, size:=0)
VarSetCapacity(ci, size)
DllCall(&quot;gdiplus\GdipGetImageEncoders&quot;, &quot;uint&quot;, count, &quot;uint&quot;, size, &quot;ptr&quot;, &amp;ci)
if !(count &amp;&amp; size)
   throw Exception(&quot;Could not get a list of image codec encoders on this system.&quot;)
Loop % count
   EncoderExtensions := StrGet(NumGet(ci, (idx:=(48+7*A_PtrSize)*(A_Index-1))+32+3*A_PtrSize, &quot;uptr&quot;), &quot;UTF-16&quot;)
      until InStr(EncoderExtensions, &quot;*.&quot; extension)
if !(pCodec := &amp;ci + idx)
   throw Exception(&quot;Could not find a matching encoder for the specified file format.&quot;)

   if !DllCall(&quot;IsClipboardFormatAvailable&quot;, &quot;UInt&quot;, CF_BITMAP := 2)
      throw &quot;There is no image in the Clipboard&quot;
   if !DllCall(&quot;OpenClipboard&quot;, &quot;Ptr&quot;, 0)
      throw &quot;OpenClipboard failed&quot;
   hDIB := DllCall(&quot;GetClipboardData&quot;, &quot;UInt&quot;, CF_DIB := 8, &quot;Ptr&quot;)
   image  := DllCall(&quot;GetClipboardData&quot;, &quot;UInt&quot;, CF_BITMAP := 2, &quot;Ptr&quot;)
   DllCall(&quot;CloseClipboard&quot;)
   if !hDIB
      throw &quot;GetClipboardData failed&quot;
   pDIB := DllCall(&quot;GlobalLock&quot;, &quot;Ptr&quot;, hDIB)
   width  := NumGet(pDIB +  4, &quot;UInt&quot;)
   height := NumGet(pDIB +  8, &quot;UInt&quot;)
   bpp    := NumGet(pDIB + 14, &quot;UShort&quot;)
   DllCall(&quot;GlobalUnlock&quot;, &quot;Ptr&quot;, pDIB)
   if (bpp != 32)
      DllCall(&quot;gdiplus\GdipCreateBitmapFromHBITMAP&quot;, &quot;Ptr&quot;, image, &quot;Ptr&quot;, 0, &quot;Ptr*&quot;, pBitmap)
   else
   {
      hdc := DllCall(&quot;CreateCompatibleDC&quot;, &quot;Ptr&quot;, 0, &quot;Ptr&quot;)
      obm := DllCall(&quot;SelectObject&quot;, &quot;Ptr&quot;, hdc, &quot;Ptr&quot;, image, &quot;Ptr&quot;)
   
      cdc := DllCall(&quot;CreateCompatibleDC&quot;, &quot;Ptr&quot;, hdc, &quot;Ptr&quot;)
      VarSetCapacity(bi, 40, 0)
      NumPut(width, bi, 4, &quot;uint&quot;)
      , NumPut(-height, bi, 8, &quot;uint&quot;)
      , NumPut(40, bi, 0, &quot;uint&quot;)
      , NumPut(1, bi, 12, &quot;ushort&quot;)
      , NumPut(0, bi, 16, &quot;uInt&quot;)
      , NumPut(bpp, bi, 14, &quot;ushort&quot;)
      hbm := DllCall(&quot;CreateDIBSection&quot;, &quot;Ptr&quot;, hdc, &quot;Ptr&quot;, &amp;bi, &quot;uint&quot;, 0, &quot;ptr*&quot;, pBits, &quot;Ptr&quot;, 0, &quot;uint&quot;, 0, &quot;Ptr&quot;)
      oB2 := DllCall(&quot;SelectObject&quot;, &quot;Ptr&quot;, cdc, &quot;Ptr&quot;, hbm, &quot;Ptr&quot;)

      DllCall(&quot;gdiplus\GdipCreateBitmapFromScan0&quot;, &quot;int&quot;, Width, &quot;int&quot;, Height, &quot;int&quot;, 0, &quot;int&quot;, 0x26200A, &quot;Ptr&quot;, 0, &quot;Ptr*&quot;, pBitmap)

      VarSetCapacity(Rect, 16, 0)
      , NumPut( width, Rect,  8, &quot;uint&quot;)
      , NumPut(height, Rect, 12, &quot;uint&quot;)
      VarSetCapacity(BitmapData, 16+2*(A_PtrSize ? A_PtrSize : 4), 0)
      , NumPut(width, BitmapData, 0, &quot;uint&quot;) ; Width
      , NumPut(height, BitmapData, 4, &quot;uint&quot;) ; Height
      , NumPut(4 * width, BitmapData,  8,   &quot;int&quot;) ; Stride
      , NumPut(0xE200B, BitmapData, 12, &quot;int&quot;) ; PixelFormat
      , NumPut(pBits, BitmapData, 16, &quot;ptr&quot;) ; Scan0
      DllCall(&quot;gdiplus\GdipBitmapLockBits&quot;, &quot;ptr&quot;, pBitmap, &quot;ptr&quot;, &amp;Rect, &quot;uint&quot;, 7, &quot;int&quot;, 0xE200B, &quot;ptr&quot;, &amp;BitmapData)
      DllCall(&quot;BitBlt&quot;, &quot;Ptr&quot;, cdc, &quot;Int&quot;, 0, &quot;Int&quot;, 0, &quot;Int&quot;, width, &quot;Int&quot;, height, &quot;Ptr&quot;, hDC , &quot;Int&quot;, 0, &quot;Int&quot;, 0, &quot;UInt&quot;, SRCCOPY := 0x00CC0020)
      DllCall(&quot;gdiplus\GdipBitmapUnlockBits&quot;, &quot;ptr&quot;,pBitmap, &quot;ptr&quot;,&amp;BitmapData)

      DllCall(&quot;SelectObject&quot;, &quot;Ptr&quot;, cdc, &quot;Ptr&quot;, ob2, &quot;Ptr&quot;)
      DllCall(&quot;DeleteDC&quot;, &quot;Ptr&quot;, cdc)
      DllCall(&quot;SelectObject&quot;, &quot;Ptr&quot;, hdc, &quot;Ptr&quot;, obm, &quot;Ptr&quot;)
      DllCall(&quot;DeleteDC&quot;, &quot;Ptr&quot;, hdc)
      DllCall(&quot;DeleteObject&quot;, &quot;Ptr&quot;, hbm)
   }
   DllCall(&quot;gdiplus\GdipSaveImageToFile&quot;, &quot;Ptr&quot;, pBitmap, &quot;WStr&quot;, &quot;gdi&quot; &quot;.jpg&quot;, &quot;Ptr&quot;, pCodec, &quot;UInt&quot;,0)
   DllCall(&quot;gdiplus\GdipDisposeImage&quot;, &quot;Ptr&quot;, pBitmap)
   DllCall(&quot;DeleteObject&quot;, &quot;Ptr&quot;, image)
</code></pre></div><p>Вопрос исчерпан.</p>]]></description>
			<author><![CDATA[null@example.com (Clannad5)]]></author>
			<pubDate>Thu, 07 Jul 2022 15:37:37 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=153810#p153810</guid>
		</item>
		<item>
			<title><![CDATA[AHK: Сохранение скриншота из буфера обмена Win11]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=153808#p153808</link>
			<description><![CDATA[<p>Здравствуйте!<br />Перерыл весь интернет, но так и не нашел способа сохранять изображение из буфера обмена.</p><p>Цель:</p><p>1. Нажать PrntScrn.<br />2. Нажать F2 чтобы активировать скрипт.<br />3. Когда скрипт активирован, сохранить скриншот из буфера обмена в формате jpg.</p><p>Самое главное чему я хочу научиться, это сохранять скриншоты сделанный через буфер обмена, без программ вроде Paint.<br />Знаю что есть библиотека GDIP, знаю что есть альтернативные скрипты, которые делают скриншоты по области, но это не даёт мне нужного ответа.</p><p>Самый главный вопрос &quot;Как сохранить буферезированное изображение, которое я либо скопировал в браузере, либо сделал его через PrntScrn?&quot;.<br />Буду рад, если сможете мне с этим помочь!</p>]]></description>
			<author><![CDATA[null@example.com (Clannad5)]]></author>
			<pubDate>Thu, 07 Jul 2022 15:23:16 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=153808#p153808</guid>
		</item>
	</channel>
</rss>
