<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; AHK: Автоматическое сохранение скриншотов в Paint]]></title>
	<link rel="self" href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=13359&amp;type=atom" />
	<updated>2018-01-10T14:24:01Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=13359</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Автоматическое сохранение скриншотов в Paint]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=122955#p122955" />
			<content type="html"><![CDATA[<p><span style="color: green"><strong>Letik</strong>, избыточное цитирование запрещено правилами. Предложение начинается с заглавной буквы и заканчиваться знаками препинания.<br />Исправьте свои сообщения!</span></p>]]></content>
			<author>
				<name><![CDATA[ypppu]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=5974</uri>
			</author>
			<updated>2018-01-10T14:24:01Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=122955#p122955</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Автоматическое сохранение скриншотов в Paint]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=122952#p122952" />
			<content type="html"><![CDATA[<p><strong>Letik</strong>, для уникального имени лучше использовать UUID:<br /></p><div class="codebox"><pre><code>MsgBox % CreateUUID()
return

CreateUUID()
{
    VarSetCapacity(puuid, 16, 0)
    if !(DllCall(&quot;rpcrt4.dll\UuidCreate&quot;, &quot;ptr&quot;, &amp;puuid))
        if !(DllCall(&quot;rpcrt4.dll\UuidToString&quot;, &quot;ptr&quot;, &amp;puuid, &quot;uint*&quot;, suuid))
            return StrGet(suuid), DllCall(&quot;rpcrt4.dll\RpcStringFree&quot;, &quot;uint*&quot;, suuid)
    return &quot;&quot;
}</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2018-01-10T13:21:42Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=122952#p122952</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Автоматическое сохранение скриншотов в Paint]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=122946#p122946" />
			<content type="html"><![CDATA[<p>Бессмысленно цитировать пост не нужно и одна тема - один вопрос.</p>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2018-01-10T12:19:09Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=122946#p122946</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Автоматическое сохранение скриншотов в Paint]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=122945#p122945" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>Malcev пишет:</cite><blockquote><div class="codebox"><pre><code>list := &quot;abcdefghijklmnopqurstuvwxyzABCDEFGHIJKLMNOPQURSTUVWXYZ0123456789&quot; 
StringSplit, letter, list
loop 6
{
   random, rand, 1, 64
   word1 .= letter%rand%
}
SaveScreenshotToFile(0, 0, A_ScreenWidth, A_ScreenHeight, word1 &quot;.png&quot;)</code></pre></div></blockquote></div><p>Кстати, вопрос не по теме, могу ли я сделать, чтобы файлы заливались в определенную папку на FTP?</p>]]></content>
			<author>
				<name><![CDATA[Letik]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=38988</uri>
			</author>
			<updated>2018-01-10T11:58:25Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=122945#p122945</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Автоматическое сохранение скриншотов в Paint]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=122944#p122944" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>Malcev пишет:</cite><blockquote><div class="codebox"><pre><code>list := &quot;abcdefghijklmnopqurstuvwxyzABCDEFGHIJKLMNOPQURSTUVWXYZ0123456789&quot; 
StringSplit, letter, list
loop 6
{
   random, rand, 1, 64
   word1 .= letter%rand%
}
SaveScreenshotToFile(0, 0, A_ScreenWidth, A_ScreenHeight, word1 &quot;.png&quot;)</code></pre></div></blockquote></div><p>Большое спасибо!</p>]]></content>
			<author>
				<name><![CDATA[Letik]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=38988</uri>
			</author>
			<updated>2018-01-10T11:50:52Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=122944#p122944</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Автоматическое сохранение скриншотов в Paint]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=122942#p122942" />
			<content type="html"><![CDATA[<div class="codebox"><pre><code>list := &quot;abcdefghijklmnopqurstuvwxyzABCDEFGHIJKLMNOPQURSTUVWXYZ0123456789&quot; 
StringSplit, letter, list
loop 6
{
   random, rand, 1, 64
   word1 .= letter%rand%
}
SaveScreenshotToFile(0, 0, A_ScreenWidth, A_ScreenHeight, word1 &quot;.png&quot;)</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2018-01-10T11:40:12Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=122942#p122942</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Автоматическое сохранение скриншотов в Paint]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=122941#p122941" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>Malcev пишет:</cite><blockquote><p>Хотя A_TickCount - не вариант. <br />Делайте так:<br /></p><div class="codebox"><pre><code>SaveScreenshotToFile(0, 0, A_ScreenWidth, A_ScreenHeight, A_Now A_Msec &quot;.png&quot;)</code></pre></div><p>Можно еще для надежности от перевода часов:<br /></p><div class="codebox"><pre><code>SaveScreenshotToFile(0, 0, A_ScreenWidth, A_ScreenHeight, A_Now A_Msec A_TickCount &quot;.png&quot;)</code></pre></div></blockquote></div><p>Работает, круто, но мне нужно, чтобы у меня отправлялся на ftp сервер PNG и TXT файл и нужное одинаковое название для обоих, а для TXT файла у меня стоит переменная, которая генерирует ему название и я хотел эту переменную в этот код засунуть, чтобы у PNG и TXT было одно название<span style="color: red"><strong>.</strong></span></p>]]></content>
			<author>
				<name><![CDATA[Letik]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=38988</uri>
			</author>
			<updated>2018-01-10T11:33:12Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=122941#p122941</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Автоматическое сохранение скриншотов в Paint]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=122938#p122938" />
			<content type="html"><![CDATA[<p>Хотя A_TickCount - не вариант. <br />Делайте так:<br /></p><div class="codebox"><pre><code>SaveScreenshotToFile(0, 0, A_ScreenWidth, A_ScreenHeight, A_Now A_Msec &quot;.png&quot;)</code></pre></div><p>Можно еще для надежности от перевода часов:<br /></p><div class="codebox"><pre><code>SaveScreenshotToFile(0, 0, A_ScreenWidth, A_ScreenHeight, A_Now A_Msec A_TickCount &quot;.png&quot;)</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2018-01-10T11:21:26Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=122938#p122938</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Автоматическое сохранение скриншотов в Paint]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=122937#p122937" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>Malcev пишет:</cite><blockquote><div class="quotebox"><cite>stealzy пишет:</cite><blockquote><p>И потом зачем рандом, если есть A_Now?</p></blockquote></div><p>А во-вашему за 1 секунду несколько снимков экрана сделать невозможно?<br /><strong>Letik</strong>, используйте в названии файла A_TickCount.</p></blockquote></div><p>Не понял, что именно в коде заменить на A_TickCount?</p>]]></content>
			<author>
				<name><![CDATA[Letik]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=38988</uri>
			</author>
			<updated>2018-01-10T11:19:42Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=122937#p122937</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Автоматическое сохранение скриншотов в Paint]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=122936#p122936" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>stealzy пишет:</cite><blockquote><p>И потом зачем рандом, если есть A_Now?</p></blockquote></div><p>А во-вашему за 1 секунду несколько снимков экрана сделать невозможно?<br /><strong>Letik</strong>, используйте в названии файла A_TickCount.</p>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2018-01-10T11:17:43Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=122936#p122936</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Автоматическое сохранение скриншотов в Paint]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=122935#p122935" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>stealzy пишет:</cite><blockquote><div class="quotebox"><cite>Letik пишет:</cite><blockquote><p>A_ScriptDir . &quot;/%word1%.png&quot;</p></blockquote></div><p>A_ScriptDir&nbsp; - это переменная, &quot;/%word1%.png&quot; - это странная строка со знаками процентов. И потом зачем рандом, если есть A_Now?</p></blockquote></div><p>Мне с рандомом нужнее, потому что файл загружает PNG и TXT документ на FTP сервер и нужны уникальные имена для каждого, а он их таки генерирует<span style="color: red"><strong>.</strong></span></p>]]></content>
			<author>
				<name><![CDATA[Letik]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=38988</uri>
			</author>
			<updated>2018-01-10T11:08:38Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=122935#p122935</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Автоматическое сохранение скриншотов в Paint]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=122930#p122930" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>teadrinker пишет:</cite><blockquote><p>Для сохранения скриншотов пайнт не нужен, тема много раз поднималась, воспользуйтесь поиском.</p></blockquote></div><p>А как сделать рандомное название для файла там?<br /></p><div class="codebox"><pre><code>SaveScreenshotToFile(0, 0, A_ScreenWidth, A_ScreenHeight, A_ScriptDir . &quot;/%word1%.png&quot;)
;Run, % A_ScriptDir . &quot;/%word1%.png&quot;

SaveScreenshotToFile(x, y, w, h, filePath)  {
   hBitmap := GetHBitmapFromScreen(x, y, w, h)
   gdip := new GDIplus
   pBitmap := gdip.BitmapFromHBitmap(hBitmap)
   DllCall(&quot;DeleteObject&quot;, Ptr, hBitmap)
   gdip.SaveBitmapToFile(pBitmap, filePath)
   gdip.DisposeImage(pBitmap)
}

GetHBitmapFromScreen(x, y, w, h)  {
   hDC := DllCall(&quot;GetDC&quot;, Ptr, 0, Ptr)
   hBM := DllCall(&quot;CreateCompatibleBitmap&quot;, Ptr, hDC, Int, w, Int, h, Ptr)
   pDC := DllCall(&quot;CreateCompatibleDC&quot;, Ptr, hDC, Ptr)
   oBM := DllCall(&quot;SelectObject&quot;, Ptr, pDC, Ptr, hBM, Ptr)
   DllCall(&quot;BitBlt&quot;, Ptr, pDC, Int, 0, Int, 0, Int, w, Int, h, Ptr, hDC, Int, x, Int, y, UInt, 0x00CC0020)
   DllCall(&quot;SelectObject&quot;, Ptr, pDC, Ptr, oBM)
   DllCall(&quot;DeleteDC&quot;, Ptr, pDC)
   DllCall(&quot;ReleaseDC&quot;, Ptr, 0, Ptr, hDC)
   Return hBM  ; should be deleted with DllCall(&quot;DeleteObject&quot;, Ptr, hBM)
}

class GDIplus   {
   __New()  {
      if !DllCall(&quot;GetModuleHandle&quot;, Str, &quot;gdiplus&quot;, Ptr)
         DllCall(&quot;LoadLibrary&quot;, Str, &quot;gdiplus&quot;)
      VarSetCapacity(si, A_PtrSize = 8 ? 24 : 16, 0), si := Chr(1)
      DllCall(&quot;gdiplus\GdiplusStartup&quot;, PtrP, pToken, Ptr, &amp;si, Ptr, 0)
      this.token := pToken
   }
   
   __Delete()  {
      DllCall(&quot;gdiplus\GdiplusShutdown&quot;, Ptr, this.token)
      if hModule := DllCall(&quot;GetModuleHandle&quot;, Str, &quot;gdiplus&quot;, Ptr)
         DllCall(&quot;FreeLibrary&quot;, Ptr, hModule)
   }
   
   BitmapFromHBitmap(hBitmap, Palette := 0)  {
      DllCall(&quot;gdiplus\GdipCreateBitmapFromHBITMAP&quot;, Ptr, hBitmap, Ptr, Palette, PtrP, pBitmap)
      return pBitmap  ; should be deleted with this.DisposeImage(pBitmap)
   }
   
   SaveBitmapToFile(pBitmap, sOutput, Quality=75)  {
      SplitPath, sOutput,,, Extension
      if Extension not in BMP,DIB,RLE,JPG,JPEG,JPE,JFIF,GIF,TIF,TIFF,PNG
         return -1

      DllCall(&quot;gdiplus\GdipGetImageEncodersSize&quot;, UIntP, nCount, UIntP, nSize)
      VarSetCapacity(ci, nSize)
      DllCall(&quot;gdiplus\GdipGetImageEncoders&quot;, UInt, nCount, UInt, nSize, Ptr, &amp;ci)
      if !(nCount &amp;&amp; nSize)
         return -2
      
      Loop, % nCount  {
         sString := StrGet(NumGet(ci, (idx := (48+7*A_PtrSize)*(A_Index-1))+32+3*A_PtrSize), &quot;UTF-16&quot;)
         if !InStr(sString, &quot;*.&quot; Extension)
            continue
         
         pCodec := &amp;ci+idx
         break
      }
      
      if !pCodec
         return -3

      if RegExMatch(Extension, &quot;i)^J(PG|PEG|PE|FIF)$&quot;) &amp;&amp; Quality != 75  {
         DllCall(&quot;gdiplus\GdipGetEncoderParameterListSize&quot;, Ptr, pBitmap, Ptr, pCodec, UintP, nSize)
         VarSetCapacity(EncoderParameters, nSize, 0)
         DllCall(&quot;gdiplus\GdipGetEncoderParameterList&quot;, Ptr, pBitmap, Ptr, pCodec, UInt, nSize, Ptr, &amp;EncoderParameters)
         Loop, % NumGet(EncoderParameters, &quot;UInt&quot;)  {
            elem := (24+A_PtrSize)*(A_Index-1) + 4 + (pad := A_PtrSize = 8 ? 4 : 0)
            if (NumGet(EncoderParameters, elem+16, &quot;UInt&quot;) = 1) &amp;&amp; (NumGet(EncoderParameters, elem+20, &quot;UInt&quot;) = 6)  {
               p := elem+&amp;EncoderParameters-pad-4
               NumPut(Quality, NumGet(NumPut(4, NumPut(1, p+0)+20, &quot;UInt&quot;)), &quot;UInt&quot;)
               break
            }
         }      
      }
      
      if A_IsUnicode
         pOutput := &amp;sOutput
      else  {
         VarSetCapacity(wOutput, StrPut(sOutput, &quot;UTF-16&quot;)*2, 0)
         StrPut(sOutput, &amp;wOutput, &quot;UTF-16&quot;)
         pOutput := &amp;wOutput
      }
      E := DllCall(&quot;gdiplus\GdipSaveImageToFile&quot;, Ptr, pBitmap, Ptr, pOutput, Ptr, pCodec, UInt, p ? p : 0)
      return E ? -5 : 0
   }
   
   DisposeImage(pBitmap)  {
      return DllCall(&quot;gdiplus\GdipDisposeImage&quot;, Ptr, pBitmap)
   }
}</code></pre></div><p>У меня такой, не получается.</p><p>Вот код рандома:<br /></p><div class="codebox"><pre><code>list := &quot;abcdefghijklmnopqurstuvwxyzABCDEFGHIJKLMNOPQURSTUVWXYZ0123456789&quot; 
StringSplit, letter, list
loop 6
{
   random, rand, 1, 64
   word1 .= letter%rand%
}</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Letik]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=38988</uri>
			</author>
			<updated>2018-01-10T06:50:14Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=122930#p122930</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Автоматическое сохранение скриншотов в Paint]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=122894#p122894" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>teadrinker пишет:</cite><blockquote><p>Для сохранения скриншотов пайнт не нужен, тема много раз поднималась, воспользуйтесь поиском.</p></blockquote></div><p>Все нашел спасибо большое за Ваш ответ в той теме<span style="color: red"><strong>.</strong></span> ))))</p>]]></content>
			<author>
				<name><![CDATA[Letik]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=38988</uri>
			</author>
			<updated>2018-01-09T19:08:05Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=122894#p122894</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Автоматическое сохранение скриншотов в Paint]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=122892#p122892" />
			<content type="html"><![CDATA[<p>Для сохранения скриншотов пайнт не нужен, тема много раз поднималась, воспользуйтесь поиском.</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2018-01-09T18:32:56Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=122892#p122892</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[AHK: Автоматическое сохранение скриншотов в Paint]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=122889#p122889" />
			<content type="html"><![CDATA[<p>Всем привет! <br />Находил такой код, но не работает (видимо из-за того что код писался на старой версии паинта)<br /></p><div class="codebox"><pre><code>SendInput, {PrintScreen}
FileAppend ,, D:\pctr.bmp
Run, mspaint.exe D:\pctr.bmp
WinWait, PrScr.bmp - Paint
PostMessage, 0x111, 57637, 0, , pctr.bmp - Paint
PostMessage, 0x111, 57603, 0, , pctr.bmp - Paint
PostMessage, 0x111, 57665, 0, , pctr.bmp - Paint
WinWaitClose, pctr.bmp - Paint</code></pre></div><p>Помогите сделать, чтоб скрипт при активации нажимал PrintScreen и сохранял скриншот в формате .png<span style="color: red"><strong>.</strong></span></p>]]></content>
			<author>
				<name><![CDATA[Letik]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=38988</uri>
			</author>
			<updated>2018-01-09T17:09:48Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=122889#p122889</id>
		</entry>
</feed>
