<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; Нажатие клавиши по появлении определенной строки в файле]]></title>
	<link rel="self" href="http://forum.script-coding.com/extern.php?action=feed&amp;tid=7477&amp;type=atom" />
	<updated>2016-08-09T06:36:09Z</updated>
	<generator>PunBB</generator>
	<id>http://forum.script-coding.com/viewtopic.php?id=7477</id>
		<entry>
			<title type="html"><![CDATA[Re: Нажатие клавиши по появлении определенной строки в файле]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=106676#p106676" />
			<content type="html"><![CDATA[<p>Можете дать готовый скрипт который. при появлении заданного вопроса в txt файле отвечает на него заданным ответом.<br />Вот пример из чатлога:</p><p>[07:02:13] <strong>Ivan_Ivanov[228]:</strong> <span class="bbu">Как дела?</span></p><p>И чтобы примерно через секунду был дан ответ на это (/sms 228 Хорошо.). ИД и Ник разные, но такого формата чтобы скрипт читал текст только.</p>]]></content>
			<author>
				<name><![CDATA[Palah]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=34110</uri>
			</author>
			<updated>2016-08-09T06:36:09Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=106676#p106676</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Нажатие клавиши по появлении определенной строки в файле]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=75176#p75176" />
			<content type="html"><![CDATA[<p>Можно пожалуйста, полный скрипт, рабочий и доделанный? )) И скажите, для чего в скрипте файл debug.txt. ??</p>]]></content>
			<author>
				<name><![CDATA[Mr_Braun]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=30686</uri>
			</author>
			<updated>2013-09-03T10:31:16Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=75176#p75176</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Нажатие клавиши по появлении определенной строки в файле]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=63033#p63033" />
			<content type="html"><![CDATA[<p>Пожалуйста <img src="//forum.script-coding.com/img/smilies/smile.png" width="15" height="15" /></p>]]></content>
			<author>
				<name><![CDATA[Irbis]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=27384</uri>
			</author>
			<updated>2012-08-22T13:28:39Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=63033#p63033</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Нажатие клавиши по появлении определенной строки в файле]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=63031#p63031" />
			<content type="html"><![CDATA[<p>Огромное спасибо за весьма стойкий скрипт, Irbis!</p>]]></content>
			<author>
				<name><![CDATA[Apache]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=27097</uri>
			</author>
			<updated>2012-08-22T12:29:54Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=63031#p63031</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Нажатие клавиши по появлении определенной строки в файле]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=63028#p63028" />
			<content type="html"><![CDATA[<p>В файле лога пустые строки - обычные символы перевода строки. Предложенный мной вариант:<br /></p><div class="codebox"><pre><code>Loop, read, chatlog.txt
   if A_LoopReadLine
      last_line := A_LoopReadLine</code></pre></div><p>- работает, но я его в исправленном скрипте не обнаружил <img src="//forum.script-coding.com/img/smilies/hmm.png" width="15" height="15" /></p><p>Ниже <strong>часть</strong> скрипта, где внесены необходимые изменения, функция получения новой непустой строки вынесена отдельно:<br /></p><div class="codebox"><pre><code>ButtonStart:
StringCaseSense, Locale
name = chatlog.txt
loop
{
lastline := GetNewLine(name)
IfInString, lastline, Следуйте к красному маячку на радаре
{
Fileappend, %lastline%`n`r, debug.txt
Sendplay z
}
IfInString, Lastline, Осталось точек
{
fileappend, %lastline%`n`r, debug.txt
sleep 1500
;Sendplay {z down}
;sleep 100
Sendplay z 
}
IfInString, lastline, стоянку и получите
{
fileappend, %Lastline%`n, debug.txt
Sleep 1500
Sendplay z
}
ifinstring, lastline, следующий рейс
{
fileappend, %lastline%`n, debug.txt
sleep 1500
Sendplay {f6}/duty{enter}
sleep 1200
Sendplay z
}
}

GetNewLine(filename)
{
   static old
   static new
   if !old
   {
      FileGetSize, old, %filename%
	  new := old
   }
   while old = new
   {
      sleep 500
      FileGetSize, new, %filename%
   }
   old := new
   Loop, read, %filename%
      if A_LoopReadLine
         last := A_LoopReadLine
   return last
}</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Irbis]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=27384</uri>
			</author>
			<updated>2012-08-22T11:36:10Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=63028#p63028</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Нажатие клавиши по появлении определенной строки в файле]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=63025#p63025" />
			<content type="html"><![CDATA[<div class="codebox"><pre><code>Gui, Add, Text, x2 y-1 w260 h20 , AntiAFK v0.8 build 17 by Apache52 aka Colin_McRae
Gui, Add, Button, x2 y19 w80 h30 , Инструкция
Gui, Add, Button, x82 y19 w80 h30 , Start
Gui, Add, Button, x162 y19 w100 h30 , Exit
Gui, Show, x390 y196 h53 w266, ANTI-AFK v0.8 build 17 by Apache52 aka Colin_McRae
Return
ButtonИнструкция:
run, readme.txt
return
ButtonExit:
GuiClose:
ExitApp


ButtonStart:
StringCaseSense, Locale
name = chatlog.txt
loop
{
FileGetSize, old, %Name%
   new := old
   while old = new
   {
      sleep 500
      FileGetSize, new, %Name%
   }
FileRead, chat, chatlog.txt ; Пробовал так
FileDelete, chat.log
FileAppend, %chat%, chat.log
Loop, read, chat.log
{

    lastline := A_LoopReadLine
}
FileReadLine, lastline, chat.log, %Number%
IfInString, lastline, Следуйте к красному маячку на радаре
{
Fileappend, %lastline%`n`r, debug.txt
Sendplay z
}
IfInString, Lastline, Осталось точек
{
fileappend, %lastline%`n`r, debug.txt
sleep 1500
;Sendplay {z down}
;sleep 100
Sendplay z 
}
IfInString, lastline, стоянку и получите
{
fileappend, %Lastline%`n, debug.txt
Sleep 1500
Sendplay z
}
ifinstring, lastline, следующий рейс
{
fileappend, %lastline%`n, debug.txt
sleep 1500
Sendplay {f6}/duty{enter}
sleep 1200
Sendplay z
}
}</code></pre></div><p>Сюда чатлог не получается нормально выложить:<br /><a href="http://rghost.ru/private/39932216/45b0c314392d3cf1c562a50ee97f7a1c">http://rghost.ru/private/39932216/45b0c … 0ee97f7a1c</a></p>]]></content>
			<author>
				<name><![CDATA[Apache]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=27097</uri>
			</author>
			<updated>2012-08-22T10:28:00Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=63025#p63025</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Нажатие клавиши по появлении определенной строки в файле]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=63024#p63024" />
			<content type="html"><![CDATA[<p>Покажи исправленный скрипт и часть файла chatlog.txt с пустыми строками (В моем понимании пустая строка состоит из перевода строки, с чем <strong>if A_LoopReadLine</strong> прекрасно справляется)<br />И конечно же, у тебя установлен AHK_L последней версии?</p>]]></content>
			<author>
				<name><![CDATA[Irbis]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=27384</uri>
			</author>
			<updated>2012-08-22T10:22:09Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=63024#p63024</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Нажатие клавиши по появлении определенной строки в файле]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=63023#p63023" />
			<content type="html"><![CDATA[<p>Исправил. Проблема остается не решенной.</p>]]></content>
			<author>
				<name><![CDATA[Apache]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=27097</uri>
			</author>
			<updated>2012-08-22T10:05:07Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=63023#p63023</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Нажатие клавиши по появлении определенной строки в файле]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=63015#p63015" />
			<content type="html"><![CDATA[<p>Для начала, в скрипте из поста <a href="http://forum.script-coding.com/viewtopic.php?pid=62956#p62956">#7</a> количество &quot;<strong>{</strong>&quot; не равно &quot;<strong>}</strong>&quot;<br />(Обрати внимание на последний <em><span style="color: magenta">IfInString</span></em>)</p><p>Во-вторых, <span style="color: white">если не обращать внимания, что скрипт сам по себе ужасен</span>, сугубо узкую задачу пропуска пустых строк можно решить так:<br /></p><div class="codebox"><pre><code>...
Loop, read, chatlog.txt
   if A_LoopReadLine
      last_line := A_LoopReadLine
...</code></pre></div><p>И, кстати, в<br /></p><div class="codebox"><pre><code>IfInString, %last_line%, строка которую нужно найти</code></pre></div><p>% % - не нужны, потому что в таком случае совпадение ищется не в last_line, а в переменной, чье имя содержится в last_line (динамическая переменная)</p>]]></content>
			<author>
				<name><![CDATA[Irbis]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=27384</uri>
			</author>
			<updated>2012-08-22T08:56:45Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=63015#p63015</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Нажатие клавиши по появлении определенной строки в файле]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=63012#p63012" />
			<content type="html"><![CDATA[<p>Прошу помочь. В файле чатлога через некоторое время появляется пустая строка (А мой скрипт читает по последней строке) из-за этого он работать не может. Прошу подсказать как можно удалить последнюю пустую строку из файла</p>]]></content>
			<author>
				<name><![CDATA[Apache]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=27097</uri>
			</author>
			<updated>2012-08-22T08:04:32Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=63012#p63012</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Нажатие клавиши по появлении определенной строки в файле]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=62956#p62956" />
			<content type="html"><![CDATA[<p>Все то же самое.<br />Сделал скрипт по другому и многофункциональней. Через час протестирую.<br /></p><div class="codebox"><pre><code>StringCaseSense, Locale
name = chatlog.txt
loop
{
   FileGetSize, old, %Name%
   new := old
   while old = new
   {
      sleep 500
      FileGetSize, new, %Name%
   }
   Loop, read, chatlog.txt

       last_line := A_LoopReadLine

   IfInString, %last_line%, Следуйте к красному маячку на радаре
   {
      Fileappend, %last_line%`n`r, debug.txt
      Send {z down}
      sleep 10
      send {z up}
   }
   IfInString, %Last_line%, Осталось точек
   {
      fileappend, %last_line%`n`r, debug.txt
      sleep 100
      Send {z down}
      sleep 10
      send {z up}
   }
   IfInString, %last_line%, стоянку и получите
   {
      fileappend, %Last_line%, debug.txt
      Sleep 100
      send {z down}
      sleep 10
      send {z up}
   }
   ifinstring, %last_line%, следующий рейс
   {
    fileappend, %last_line%, debug.txt
    sleep 1000
    send {f6}/duty{enter}
    sleep 1000
    send {z down}
    sleep 10
    send {z up}
}</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Apache]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=27097</uri>
			</author>
			<updated>2012-08-20T08:06:07Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=62956#p62956</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Нажатие клавиши по появлении определенной строки в файле]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=62955#p62955" />
			<content type="html"><![CDATA[<p>Не-не-не, не нужно прям так сразу «задачу ставить», мы же ошибки ищем <img src="//forum.script-coding.com/img/smilies/smile.png" width="15" height="15" /><br /></p><div class="codebox"><pre><code>...
If !CurrentWord
   FileAppend, Not Detect (%A_Index%)`n, log.log
Else
   {
   Send, {Shift Down}
   Sleep, 10
   Send, {Shift Up}
   }
...</code></pre></div>]]></content>
			<author>
				<name><![CDATA[creature.ws]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=26105</uri>
			</author>
			<updated>2012-08-20T07:26:38Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=62955#p62955</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Нажатие клавиши по появлении определенной строки в файле]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=62953#p62953" />
			<content type="html"><![CDATA[<div class="codebox"><pre><code>name = chatlog.txt
Loop
{
FileGetSize, old_s, %Name%
   new_s := old_s
   while old_s = new_s {
      sleep 500
      FileGetSize, new_s, %Name%
   }
StringCaseSense, Locale
FindWords := &quot;Объявление&quot; 
Loop, Parse, FindWords, `, 
   {
      FileRead, OutPutVar, %A_ScriptDir%\chatlog.txt
      IfInString, OutPutVar, % A_LoopField
         {
            CurrentWord := % A_LoopField
            FoundWords .= &quot;, &quot;CurrentWord
            FoundWordsNum++
         }
   }
StringTrimLeft, FoundWords2, FoundWords, 1
StringTrimLeft, CountEmptyStringNum2, CountEmptyStringNum, 1
If !CurrentWord
   FileAppend, Not Detect (%A_Index%)`n, log.log
   {
   Send, {Shift Down}
   Sleep, 10
   Send, {Shift Up}
   }
 
}
return
F5::
ExitApp</code></pre></div><p>Задача скрипта:<br />Есть txt файл с неизвестным количеством строк. Строки практически все разные.<br />Из игры каждая строка записывается в этот txt файл.<br />При изменении размера файла должен происходить поиск слова со строки без повторений.<br />При нахождении слова или выражения должен нажимать на шифт.</p>]]></content>
			<author>
				<name><![CDATA[Apache]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=27097</uri>
			</author>
			<updated>2012-08-20T06:42:22Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=62953#p62953</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Нажатие клавиши по появлении определенной строки в файле]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=62952#p62952" />
			<content type="html"><![CDATA[<p>Нет предела совершенству, продемонстрируйте текущую версию своего скрипта.</p>]]></content>
			<author>
				<name><![CDATA[creature.ws]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=26105</uri>
			</author>
			<updated>2012-08-20T06:21:57Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=62952#p62952</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Нажатие клавиши по появлении определенной строки в файле]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=62951#p62951" />
			<content type="html"><![CDATA[<p>Скрипт продолжает не работать. Независимо от строчки персонаж нажимает на шифт всегда.</p>]]></content>
			<author>
				<name><![CDATA[Apache]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=27097</uri>
			</author>
			<updated>2012-08-20T06:16:07Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=62951#p62951</id>
		</entry>
</feed>
