<?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="http://forum.script-coding.com/extern.php?action=feed&amp;tid=8453&amp;type=atom" />
	<updated>2013-07-07T13:24:14Z</updated>
	<generator>PunBB</generator>
	<id>http://forum.script-coding.com/viewtopic.php?id=8453</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Как читать нетекстовые файлы?]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=73539#p73539" />
			<content type="html"><![CDATA[<p>Например, такой функцией. Вывести 32 байта группами по 4.<br /></p><div class="codebox"><pre><code>
file := FileOpen(&quot;c:\1.bmp&quot;, &quot;r&quot;)
ret := file.RawRead(buf, file.length)
file.Close()

hex := bin2hex(buf, 32, 4)

MsgBox, %hex%

bin2hex(ByRef buf, bytes, group = 0)
{
    tmp := A_FormatInteger
    SetFormat, Integer, Hex
    Loop, %bytes%
    {
        hex .= SubStr(&quot;0&quot; . SubStr(NumGet(buf, A_Index - 1, &quot;UChar&quot;), 3), -1)
        If (group &gt; 0) &amp;&amp; !Mod(A_Index, group)
            hex .= &quot; &quot;
    }
    SetFormat, Integer, %tmp%
    Return hex
}
</code></pre></div>]]></content>
			<author>
				<name><![CDATA[YMP]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=81</uri>
			</author>
			<updated>2013-07-07T13:24:14Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=73539#p73539</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Как читать нетекстовые файлы?]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=73538#p73538" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>YMP пишет:</cite><blockquote><p>Хекс-представление — это уже строка, текст.</p></blockquote></div><p>&nbsp; А как же её получить из bmp, avi, и т.п. средствами AHK?</p>]]></content>
			<author>
				<name><![CDATA[Next]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=28517</uri>
			</author>
			<updated>2013-07-07T12:23:27Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=73538#p73538</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Как читать нетекстовые файлы?]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=73537#p73537" />
			<content type="html"><![CDATA[<p>Бинарные файлы редактируют в хекс-редакторах. Т.е. значения байтов переводятся в 16-ричные числа и в таком виде показываются. При сохранении изменений — обратный перевод. Вы можете так же попробовать. Хекс-представление — это уже строка, текст.</p>]]></content>
			<author>
				<name><![CDATA[YMP]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=81</uri>
			</author>
			<updated>2013-07-07T11:02:29Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=73537#p73537</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Как читать нетекстовые файлы?]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=73536#p73536" />
			<content type="html"><![CDATA[<p>Да, работает. <br /> Но как мне редактировать таким образом прочитанный файл?&nbsp; Я ожидал увидеть информацию в таком же виде, как и в обычных текстовых файлах и определённым образом её редактировать.</p>]]></content>
			<author>
				<name><![CDATA[Next]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=28517</uri>
			</author>
			<updated>2013-07-07T10:39:42Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=73536#p73536</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Как читать нетекстовые файлы?]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=73535#p73535" />
			<content type="html"><![CDATA[<p>Смотреть этот буфер как текст бесполезно, т.к. там содержатся нулевые байты, которые в тексте обозначают конец строки. Сохраните этот буфер в другой файл методом RawWrite и потом сравните исходный файл и эту копию.<br /></p><div class="codebox"><pre><code>
file := FileOpen(&quot;C:\1.bmp&quot;, &quot;r&quot;)
ret := file.RawRead(buf, file.length)
file.Close()

file := FileOpen(&quot;C:\2.bmp&quot;, &quot;w&quot;)
file.RawWrite(buf, ret)
file.Close()
</code></pre></div>]]></content>
			<author>
				<name><![CDATA[YMP]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=81</uri>
			</author>
			<updated>2013-07-07T09:15:44Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=73535#p73535</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Как читать нетекстовые файлы?]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=73534#p73534" />
			<content type="html"><![CDATA[<p>Я открывал перед этим bmp с помощью Notepad++ и ожидал увидеть при чтении скриптом что-то аналогично. И мне сложно представить, что содержимое bmp-файла 10x10 пикселей поместилось в два символа.</p>]]></content>
			<author>
				<name><![CDATA[Next]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=28517</uri>
			</author>
			<updated>2013-07-07T08:52:19Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=73534#p73534</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Как читать нетекстовые файлы?]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=73533#p73533" />
			<content type="html"><![CDATA[<p>Да, в неё. А как вы определили, что не то?</p>]]></content>
			<author>
				<name><![CDATA[YMP]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=81</uri>
			</author>
			<updated>2013-07-07T08:14:29Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=73533#p73533</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Как читать нетекстовые файлы?]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=73532#p73532" />
			<content type="html"><![CDATA[<p>А куда собственно само прочитанное помещается? В переменную &quot;buf&quot;? Что-то у меня в ней не то...</p>]]></content>
			<author>
				<name><![CDATA[Next]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=28517</uri>
			</author>
			<updated>2013-07-07T07:56:52Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=73532#p73532</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Как читать нетекстовые файлы?]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=73531#p73531" />
			<content type="html"><![CDATA[<p>Спасибо! Попробую.</p>]]></content>
			<author>
				<name><![CDATA[Next]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=28517</uri>
			</author>
			<updated>2013-07-07T07:52:00Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=73531#p73531</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Как читать нетекстовые файлы?]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=73527#p73527" />
			<content type="html"><![CDATA[<p>Есть объект File и его метод RawRead.<br /></p><div class="codebox"><pre><code>
file := FileOpen(&quot;C:\1.bmp&quot;, &quot;r&quot;)
ret := file.RawRead(buf, file.length)
file.Close()

MsgBox, Прочитано %ret% байт
</code></pre></div><p>Кстати, поправьте заголовок темы (префикс), пока модератор не заругался.</p>]]></content>
			<author>
				<name><![CDATA[YMP]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=81</uri>
			</author>
			<updated>2013-07-07T02:44:04Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=73527#p73527</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[AHK: Как читать нетекстовые файлы?]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=73526#p73526" />
			<content type="html"><![CDATA[<p>Не могу прочитать даже маленький файл *.bmp</p><p> Применил простые <br /></p><div class="codebox"><pre><code>
FileRead, var, C:\1.bmp
FileAppend, %var%, C:\1.txt</code></pre></div><p> В txt попадает только первая часть &quot;BMv&quot;.</p>]]></content>
			<author>
				<name><![CDATA[Next]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=28517</uri>
			</author>
			<updated>2013-07-06T23:59:09Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=73526#p73526</id>
		</entry>
</feed>
