<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Серый форум &mdash; AHK: Не получается сделать сравнение]]></title>
		<link>https://forum.script-coding.com/viewtopic.php?id=17335</link>
		<atom:link href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=17335&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[Недавние сообщения в теме «AHK: Не получается сделать сравнение».]]></description>
		<lastBuildDate>Fri, 26 Aug 2022 00:47:54 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: AHK: Не получается сделать сравнение]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=154514#p154514</link>
			<description><![CDATA[<p><strong>Clannad5</strong> Огромное вам спасибо!</p>]]></description>
			<author><![CDATA[null@example.com (KEKS1K)]]></author>
			<pubDate>Fri, 26 Aug 2022 00:47:54 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=154514#p154514</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Не получается сделать сравнение]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=154513#p154513</link>
			<description><![CDATA[<p><strong>KEKS1K</strong><br />Обратите внимание, что папки нужно заранее создать, либо делайте это вручную, либо проверяйте папку на наличии нужных директив и если их нет - создавайте соответствующей командой.</p><div class="codebox"><pre><code>

F1::
Gosub skr
return

skr:
time := A_NowUTC
time += 3, H
FormatTime, vDate,% time, HH_mm_ss ; 
VHH := SubStr(vDate, 1, 2) ; Извлекаем из первой позиции (это у нас H) два символа (это у нас HH получается)
VMM := SubStr(vDate, 4, 2) ;  Извлекаем из четвертой позиции (это у нас m) два символа (это у нас mm получается)
if (VHH = 21) and (VMM &gt; 00) or (VHH &gt; 21) ; Если равно 21 час и больше 00 минут ИЛИ больше 21 часа (например 22 часа)
Dira := &quot;\Dir21&quot; ; то засунем в папку Dir21
else
Dira := &quot;\Dir00&quot; ; Если не подходит условия, то засунем скриншоты сюда
vDate := &quot;\&quot; vDate &quot;.png&quot; ; 
screenshot:=(A_ScriptDir . Dira . vDate) ; 
msgbox, %screenshot%
SaveScreenshotToFile(0, 0, A_ScreenWidth, A_ScreenHeight, screenshot)

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
}

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
	}
	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)
	}
}
Return
</code></pre></div><p>Это своеобразный пример из примерно того, что вы хотели.<br />Если головой подумаете, сможете довести до идеала.</p>]]></description>
			<author><![CDATA[null@example.com (Clannad5)]]></author>
			<pubDate>Fri, 26 Aug 2022 00:44:40 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=154513#p154513</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Не получается сделать сравнение]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=154512#p154512</link>
			<description><![CDATA[<div class="quotebox"><cite>KEKS1K пишет:</cite><blockquote><p>я кодер начинающий</p></blockquote></div><p>Ну вот и начинайте! Чтобы узнать, как устроена переменная time, её можно отобразить в MsgBox:<br /></p><div class="codebox"><pre><code>...
time += 3, H
MsgBox, % time</code></pre></div><p>Сразу станет понятно, где там часы. Их можно выделить с помощью SubStr() (читайте справку).</p>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Thu, 25 Aug 2022 19:22:05 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=154512#p154512</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Не получается сделать сравнение]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=154511#p154511</link>
			<description><![CDATA[<p><strong>teadrinker</strong><br />Можете в виде кода показать пожалуйста?<br />А то я кодер начинающий, и вообще не понимаю как это реализовать.<br />Даже примерно незнаю!</p>]]></description>
			<author><![CDATA[null@example.com (KEKS1K)]]></author>
			<pubDate>Thu, 25 Aug 2022 18:54:45 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=154511#p154511</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Не получается сделать сравнение]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=154510#p154510</link>
			<description><![CDATA[<p>Выделите из переменной time время в часах, затем сравните с 21.</p>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Thu, 25 Aug 2022 18:48:56 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=154510#p154510</guid>
		</item>
		<item>
			<title><![CDATA[AHK: Не получается сделать сравнение]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=154508#p154508</link>
			<description><![CDATA[<p>У меня не получается сделать так, чтобы после скриншота он закидался в разные папки.<br />То-есть если скриншот был сделан до 21:00,то в одну папку, а если после 21:00,то в другую.<br />Вот сам код:<br /></p><div class="codebox"><pre><code>
F1::
Gosub skr
return

skr:
time := A_NowUTC
time += 3, H
FormatTime, vDate,% time, HH_mm_ss ; 
vDate := &quot;\&quot; vDate &quot;.png&quot; ; 
msgbox, % vDate ; 
screenshot:=(A_ScriptDir . vDate) ; 
SaveScreenshotToFile(0, 0, A_ScreenWidth, A_ScreenHeight, screenshot)

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
}

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
	}
	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)
	}
}
Return</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (KEKS1K)]]></author>
			<pubDate>Thu, 25 Aug 2022 17:41:23 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=154508#p154508</guid>
		</item>
	</channel>
</rss>
