<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Серый форум &mdash; AHK: Чтение .txt и выполнение команды]]></title>
		<link>http://forum.script-coding.com/viewtopic.php?id=12323</link>
		<atom:link href="http://forum.script-coding.com/extern.php?action=feed&amp;tid=12323&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[Недавние сообщения в теме «AHK: Чтение .txt и выполнение команды».]]></description>
		<lastBuildDate>Tue, 17 Jan 2017 22:08:51 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: AHK: Чтение .txt и выполнение команды]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=111199#p111199</link>
			<description><![CDATA[<div class="quotebox"><cite>belyankin12 пишет:</cite><blockquote><p>Кстати, если так подумать, вы прочитаете все содержимое чатлога. Ваш способ мне кажется не самый безопасный...</p></blockquote></div><p> Можно зашифровать содержимое чат-лога, это не сложно.</p><p>Например используя&nbsp; функцию расчёта HASH, ключом будет например EXE-file.</p><p>Функция поддерживает HASH типы(MD2/MD5/SHA - поддержка всеми Windows, SHA256/SHA384/SHA512 - не поддерживается Windows XP/2000).<br /></p><div class="fancy_spoiler_switcher"><div class="fancy_spoiler_switcher_header"><strong>+</strong>&nbsp;Функция fnHASH</div><div class="fancy_spoiler"><div class="codebox"><pre><code>;-----------------------------------------------------------------------------------------------------------------
;                                  Функция расчёта контрольной суммы файла
; HASH типы: MD2/MD5/SHA - поддержка всеми Windows, SHA256/SHA384/SHA512 - не поддерживается Windows XP/2000
;-----------------------------------------------------------------------------------------------------------------

;НА ВХОД:
; 1-й параметр(STRING): Полный путь к файлу
; 2-й параметр(STRING): HASH-типы из списка MD2/MD5/SHA/SHA256/SHA384/SHA512

;НА ВЫХОД:
; Или контольная сумма файла(STRING)
; Или слово &quot;ERROR&quot;(STRING)

fnHASH(FilePath, str)
{
  CaseSensitive := False ; Не чувствительность к регистру, те Б = б
  if (str = &quot;MD2&quot;)
        vHASH := 1
  Else if (str = &quot;MD5&quot;)
        vHASH := 2
  Else if (str = &quot;SHA&quot;)
        vHASH := 3
  Else if (str = &quot;SHA256&quot;)
        vHASH := 4
  Else if (str = &quot;SHA384&quot;)
        vHASH := 5
  Else if (str = &quot;SHA512&quot;)
        vHASH := 6
          Else
              Return &quot;ERROR&quot;
  CaseSensitive := True ; Чувствительность к регистру, те Б != б
  ret := HashFile(FilePath,vHASH)
Return ret
}

/*
HASH types:
1 - MD2
2 - MD5
3 - SHA
4 - SHA256 - not supported on XP,2000
5 - SHA384 - not supported on XP,2000
6 - SHA512 - not supported on XP,2000
*/

HashFile(filePath,hashType=2)
{
	PROV_RSA_AES := 24
	CRYPT_VERIFYCONTEXT := 0xF0000000
	BUFF_SIZE := 1024 * 1024 ; 1 MB
	HP_HASHVAL := 0x0002
	HP_HASHSIZE := 0x0004
	
	HASH_ALG := hashType = 1 ? (CALG_MD2 := 32769) : HASH_ALG
	HASH_ALG := hashType = 2 ? (CALG_MD5 := 32771) : HASH_ALG
	HASH_ALG := hashType = 3 ? (CALG_SHA := 32772) : HASH_ALG
	HASH_ALG := hashType = 4 ? (CALG_SHA_256 := 32780) : HASH_ALG	;Vista+ only
	HASH_ALG := hashType = 5 ? (CALG_SHA_384 := 32781) : HASH_ALG	;Vista+ only
	HASH_ALG := hashType = 6 ? (CALG_SHA_512 := 32782) : HASH_ALG	;Vista+ only
	
	f := FileOpen(filePath,&quot;r&quot;,&quot;CP0&quot;)
	if !IsObject(f)
		return 0
	if !hModule := DllCall( &quot;GetModuleHandleW&quot;, &quot;str&quot;, &quot;Advapi32.dll&quot;, &quot;Ptr&quot; )
		hModule := DllCall( &quot;LoadLibraryW&quot;, &quot;str&quot;, &quot;Advapi32.dll&quot;, &quot;Ptr&quot; )
	if !dllCall(&quot;Advapi32\CryptAcquireContextW&quot;
				,&quot;Ptr*&quot;,hCryptProv
				,&quot;Uint&quot;,0
				,&quot;Uint&quot;,0
				,&quot;Uint&quot;,PROV_RSA_AES
				,&quot;UInt&quot;,CRYPT_VERIFYCONTEXT )
		Goto,FreeHandles
	
	if !dllCall(&quot;Advapi32\CryptCreateHash&quot;
				,&quot;Ptr&quot;,hCryptProv
				,&quot;Uint&quot;,HASH_ALG
				,&quot;Uint&quot;,0
				,&quot;Uint&quot;,0
				,&quot;Ptr*&quot;,hHash )
		Goto,FreeHandles
	
	VarSetCapacity(read_buf,BUFF_SIZE,0)
	
    hCryptHashData := DllCall(&quot;GetProcAddress&quot;, &quot;Ptr&quot;, hModule, &quot;AStr&quot;, &quot;CryptHashData&quot;, &quot;Ptr&quot;)
	While (cbCount := f.RawRead(read_buf, BUFF_SIZE))
	{
		if (cbCount = 0)
			break
		
		if !dllCall(hCryptHashData
					,&quot;Ptr&quot;,hHash
					,&quot;Ptr&quot;,&amp;read_buf
					,&quot;Uint&quot;,cbCount
					,&quot;Uint&quot;,0 )
			Goto,FreeHandles
	}
	
	if !dllCall(&quot;Advapi32\CryptGetHashParam&quot;
				,&quot;Ptr&quot;,hHash
				,&quot;Uint&quot;,HP_HASHSIZE
				,&quot;Uint*&quot;,HashLen
				,&quot;Uint*&quot;,HashLenSize := 4
				,&quot;UInt&quot;,0 ) 
		Goto,FreeHandles
		
	VarSetCapacity(pbHash,HashLen,0)
	if !dllCall(&quot;Advapi32\CryptGetHashParam&quot;
				,&quot;Ptr&quot;,hHash
				,&quot;Uint&quot;,HP_HASHVAL
				,&quot;Ptr&quot;,&amp;pbHash
				,&quot;Uint*&quot;,HashLen
				,&quot;UInt&quot;,0 )
		Goto,FreeHandles	
	
	SetFormat,integer,Hex
	loop,%HashLen%
	{
		num := numget(pbHash,A_index-1,&quot;UChar&quot;)
		hashval .= substr((num &gt;&gt; 4),0) . substr((num &amp; 0xf),0)
	}
	SetFormat,integer,D
		
FreeHandles:
	f.Close()
	DllCall(&quot;FreeLibrary&quot;, &quot;Ptr&quot;, hModule)
	dllCall(&quot;Advapi32\CryptDestroyHash&quot;,&quot;Ptr&quot;,hHash)
	dllCall(&quot;Advapi32\CryptReleaseContext&quot;,&quot;Ptr&quot;,hCryptProv,&quot;UInt&quot;,0)
	return hashval
}</code></pre></div></div></div>]]></description>
			<author><![CDATA[null@example.com (Indomito)]]></author>
			<pubDate>Tue, 17 Jan 2017 22:08:51 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=111199#p111199</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Чтение .txt и выполнение команды]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=111195#p111195</link>
			<description><![CDATA[<p><strong>KenzoHK</strong><br />Попробуй разбирать каждую строку,&nbsp; да и &quot;чек&quot; может быть частью слова, желательно использовать ключ, например &quot;%чек&quot;.<br />Хотя, если это единственно слово в строке, то не нужно огород городить, а проще использовать:<br /> — простое чтение строк <strong>Loop, Read, InputFile [, OutputFile]</strong>;<br /> — разбор строки <strong>Loop, Parse, InputVar [, Delimiters, OmitChars]</strong>.</p><br /><p>Пример самого простого разбора. </p><div class="codebox"><pre><code>Haystack  := &quot;C:\AHK Compiler\AHK Compiler.exe&quot;
Needle  := &quot;\&quot;
a := InStr(Haystack, Needle , , 0)
vDir := SubStr(Haystack, 1 , a-1)
vFile := SubStr(Haystack, a+1)
MsgBox %vDir% --- %vFile%</code></pre></div><p>Удачи с чеками. <img src="//forum.script-coding.com/img/smilies/smile.png" width="15" height="15" /></p>]]></description>
			<author><![CDATA[null@example.com (Indomito)]]></author>
			<pubDate>Tue, 17 Jan 2017 21:21:47 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=111195#p111195</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Чтение .txt и выполнение команды]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=111171#p111171</link>
			<description><![CDATA[<p>Кстати, если так подумать, вы прочитаете все содержимое чатлога. Ваш способ мне кажется не самый безопасный. Так, можно активировать команду любому игроку, что напишет кодовое слово, не так ли?</p>]]></description>
			<author><![CDATA[null@example.com (belyankin12)]]></author>
			<pubDate>Tue, 17 Jan 2017 07:16:17 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=111171#p111171</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Чтение .txt и выполнение команды]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=111157#p111157</link>
			<description><![CDATA[<p><strong><em>string</em> </strong>- это не часть выражения, а имя переменной. Вам следует на место этого слова подставить <strong><em>sms</em></strong>.</p>]]></description>
			<author><![CDATA[null@example.com (ypppu)]]></author>
			<pubDate>Mon, 16 Jan 2017 15:47:55 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=111157#p111157</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Чтение .txt и выполнение команды]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=111156#p111156</link>
			<description><![CDATA[<p><strong>ypppu</strong>, это понятно.<br />Вот мой код, но он не в какую не хочет выполнять команды.<br /></p><div class="codebox"><pre><code>login:= &quot;чек&quot; 
FileRead, sms, %A_MyDocuments%\GTA San Andreas User Files\SAMP\chatlog.txt    
If string contains %login%
(Дальше идут сами действия)</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (KenzoHK)]]></author>
			<pubDate>Mon, 16 Jan 2017 15:24:44 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=111156#p111156</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Чтение .txt и выполнение команды]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=111155#p111155</link>
			<description><![CDATA[<p><a href="http://www.script-coding.com/AutoHotkey/FileRead.html">FileRead</a>.</p>]]></description>
			<author><![CDATA[null@example.com (ypppu)]]></author>
			<pubDate>Mon, 16 Jan 2017 15:20:46 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=111155#p111155</guid>
		</item>
		<item>
			<title><![CDATA[AHK: Чтение .txt и выполнение команды]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=111154#p111154</link>
			<description><![CDATA[<p>Есть .txt файл в нем определенное слово, как сделать чтобы это слово читало и начало выполнять команду.</p>]]></description>
			<author><![CDATA[null@example.com (KenzoHK)]]></author>
			<pubDate>Mon, 16 Jan 2017 15:17:39 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=111154#p111154</guid>
		</item>
	</channel>
</rss>
