<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; AHK: Как можно поместить фото в буффер]]></title>
	<link rel="self" href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=16698&amp;type=atom" />
	<updated>2021-11-02T17:53:16Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=16698</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Как можно поместить фото в буффер]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=150375#p150375" />
			<content type="html"><![CDATA[<div class="codebox"><pre><code>filePath := &quot;C:\Users\RaDley\Documents\Lightshot\Screenshot_10.png&quot;

GDIp := new GDIplus
pBitmam := GDIp.CreateBitmapFromFile(filePath)
GDIp.SetBitmapToClipboard(pBitmam)
GDIp.DisposeImage(pBitmap)

class GDIplus {
   __New() {
      this.hLib := DllCall(&quot;LoadLibrary&quot;, &quot;Str&quot;, &quot;gdiplus&quot;, &quot;Ptr&quot;)
      VarSetCapacity(si, 8 + A_PtrSize*2, 0), si := Chr(1)
      DllCall(&quot;gdiplus\GdiplusStartup&quot;, &quot;PtrP&quot;, pToken, &quot;Ptr&quot;, &amp;si, &quot;Ptr&quot;, 0)
      this.token := pToken
   }
   __Delete() {
      DllCall(&quot;gdiplus\GdiplusShutdown&quot;, &quot;Ptr&quot;, this.token)
      DllCall(&quot;FreeLibrary&quot;, &quot;Ptr&quot;, this.hLib)
   }
   CreateBitmapFromFile(sFile) {
      DllCall(&quot;gdiplus\GdipCreateBitmapFromFile&quot;, &quot;WStr&quot;, sFile, &quot;PtrP&quot;, pBitmap)
      Return pBitmap
   }
   SetBitmapToClipboard(pBitmap) {
      hBitmap := this.CreateHBITMAPFromBitmap(pBitmap)
      off1 := A_PtrSize = 8 ? 52 : 44, off2 := A_PtrSize = 8 ? 32 : 24
      DllCall(&quot;GetObject&quot;, &quot;Ptr&quot;, hBitmap, &quot;int&quot;, VarSetCapacity(oi, A_PtrSize = 8 ? 104 : 84, 0), &quot;Ptr&quot;, &amp;oi)
      hdib := DllCall(&quot;GlobalAlloc&quot;, &quot;UInt&quot;, 2, &quot;Ptr&quot;, 40+NumGet(oi, off1, &quot;UInt&quot;), &quot;Ptr&quot;)
      pdib := DllCall(&quot;GlobalLock&quot;, &quot;Ptr&quot;, hdib, &quot;Ptr&quot;)
      DllCall(&quot;RtlMoveMemory&quot;, &quot;Ptr&quot;, pdib, &quot;Ptr&quot;, &amp;oi+off2, &quot;Ptr&quot;, 40)
      DllCall(&quot;RtlMoveMemory&quot;, &quot;Ptr&quot;, pdib+40, &quot;Ptr&quot;, NumGet(oi, off2 - A_PtrSize, &quot;Ptr&quot;), &quot;Ptr&quot;, NumGet(oi, off1, &quot;UInt&quot;))
      DllCall(&quot;GlobalUnlock&quot;, &quot;Ptr&quot;, hdib)
      DllCall(&quot;DeleteObject&quot;, &quot;Ptr&quot;, hBitmap)
      DllCall(&quot;OpenClipboard&quot;, &quot;Ptr&quot;, 0)
      DllCall(&quot;EmptyClipboard&quot;)
      DllCall(&quot;SetClipboardData&quot;, &quot;UInt&quot;, 8, &quot;Ptr&quot;, hdib)
      DllCall(&quot;CloseClipboard&quot;)
   }
	CreateHBITMAPFromBitmap(pBitmap, Background=0xffffffff) {
		DllCall(&quot;gdiplus\GdipCreateHBITMAPFromBitmap&quot;, &quot;Ptr&quot;, pBitmap, &quot;PtrP&quot;, hbm, &quot;Int&quot;, Background)
		return hbm
	}
	DisposeImage(pBitmap)  {
		return DllCall(&quot;gdiplus\GdipDisposeImage&quot;, &quot;Ptr&quot;, pBitmap)
	}
}</code></pre></div>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2021-11-02T17:53:16Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=150375#p150375</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Как можно поместить фото в буффер]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=150372#p150372" />
			<content type="html"><![CDATA[<p>Зачем нам лёгкие пути? Мы любим посложнее.</p>]]></content>
			<author>
				<name><![CDATA[__Михаил__]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=40928</uri>
			</author>
			<updated>2021-11-02T17:39:47Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=150372#p150372</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Как можно поместить фото в буффер]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=150371#p150371" />
			<content type="html"><![CDATA[<p>А без пайнта никак? <img src="//forum.script-coding.com/img/smilies/smile.png" width="15" height="15" /></p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2021-11-02T17:37:15Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=150371#p150371</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Как можно поместить фото в буффер]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=150366#p150366" />
			<content type="html"><![CDATA[<p>Примерно так:</p><div class="codebox"><pre><code>F2::	; 1 нажатие: Сохранить картинку в буфер, 2 нажатие: Открыть Paint и вставить её из буфера.
F++
If (F = 1){
 Clipboard=
 FileName := C:\Users\RaDley\Documents\Lightshot\Screenshot_10.png
 Run, MSPaint %FileName%
 WinWait, ahk_class MSPaintApp
 Sleep, 100
 Send, ^{a}
 Sleep, 100
 Send, ^{c}
 ToolTip, Картинка в буфере
 PostMessage, 0x111, 57665, 0,, ahk_class MSPaintApp
 Sleep, 500
 WinWaitClose
 ToolTip
} 

If (F = 2){
 ToolTip, Картинка из буфера
 Run, MSPaint
 WinWait, ahk_class MSPaintApp
 Sleep, 100
 Send, ^{v}
 F := 0
 Sleep, 500
 ToolTip
}
Return</code></pre></div>]]></content>
			<author>
				<name><![CDATA[__Михаил__]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=40928</uri>
			</author>
			<updated>2021-11-02T16:26:35Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=150366#p150366</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Как можно поместить фото в буффер]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=150364#p150364" />
			<content type="html"><![CDATA[<p>Открыть в Paint(можно без отображения окна), потом ^A^C.</p>]]></content>
			<author>
				<name><![CDATA[Foma]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=31521</uri>
			</author>
			<updated>2021-11-02T14:27:03Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=150364#p150364</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[AHK: Как можно поместить фото в буффер]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=150362#p150362" />
			<content type="html"><![CDATA[<p>Здравствуйте, у меня есть фото оно находится к примеру по пути: &quot;C:\Users\RaDley\Documents\Lightshot\Screenshot_10.png&quot;<br />Как можно поместить это изображение в Clipboard?</p>]]></content>
			<author>
				<name><![CDATA[RaDley]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=41634</uri>
			</author>
			<updated>2021-11-02T11:49:34Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=150362#p150362</id>
		</entry>
</feed>
