<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; AHK: Cчитать текст из файла и поместить в переменную]]></title>
	<link rel="self" href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=11767&amp;type=atom" />
	<updated>2022-10-29T11:07:38Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=11767</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Cчитать текст из файла и поместить в переменную]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=155470#p155470" />
			<content type="html"><![CDATA[<p><strong>teadrinker</strong> Понял.</p>]]></content>
			<author>
				<name><![CDATA[Ядрён]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=30092</uri>
			</author>
			<updated>2022-10-29T11:07:38Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=155470#p155470</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Cчитать текст из файла и поместить в переменную]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=155466#p155466" />
			<content type="html"><![CDATA[<p><strong>Ядрён</strong>, для тем по играм есть своя ветка.</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2022-10-29T10:48:31Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=155466#p155466</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Cчитать текст из файла и поместить в переменную]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=155460#p155460" />
			<content type="html"><![CDATA[<p><strong>teadrinker</strong> Спвсибо!</p>]]></content>
			<author>
				<name><![CDATA[Ядрён]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=30092</uri>
			</author>
			<updated>2022-10-29T10:41:02Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=155460#p155460</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Cчитать текст из файла и поместить в переменную]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=155453#p155453" />
			<content type="html"><![CDATA[<p>Спасибо разобрался, символ перевода строки (`n) был прописан с ошибкой.</p>]]></content>
			<author>
				<name><![CDATA[Ядрён]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=30092</uri>
			</author>
			<updated>2022-10-29T10:29:54Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=155453#p155453</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Cчитать текст из файла и поместить в переменную]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=155435#p155435" />
			<content type="html"><![CDATA[<p><strong>Ядрён</strong><br />А я бы Loop, Read использовал бы. Ну каждому своё.</p>]]></content>
			<author>
				<name><![CDATA[andrey.a.polyakov.b2c]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=42228</uri>
			</author>
			<updated>2022-10-28T18:51:05Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=155435#p155435</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Cчитать текст из файла и поместить в переменную]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=155355#p155355" />
			<content type="html"><![CDATA[<p>Доброго времени суток. Подскажите пожалуйста почему не считывается текст из файл &#039;&#039;555.amc&#039;&#039; если я записываю его при помощи этого скрипта.<br /></p><div class="codebox"><pre><code>*~vk60::
  KeyWait, LButton, D 
  MouseGetPos, pos1, pos2
   WinGet, active_id, ID, A 
if !x0
    x0 := - pos1, y0 := - pos2
  Else
{
      FileAppend,% &quot;MoveR &quot; - pos1 - x0 &quot; &quot; - pos2 - y0 &quot;`n&quot;, 555.amc
      FileAppend,% &quot;Delay &quot; . A_TimeSincePriorHotkey . &quot; ms&quot; &quot;`n&quot;, 555.amc
      FileAppend,% &quot;IfKey 1 0 1&quot; &quot;`n&quot;, 555.amc
      x0 := - pos1, y0 := - pos2
   }
 Return
</code></pre></div><p>Скрипт для считывания.<br /></p><div class="codebox"><pre><code>*~vk31::
FileSelectFile, SelectedFile, 24, , Загрузить макрос, *.amc

Arr := []

text := FileOpen(SelectedFile,&quot;r&quot;).Read()
While pEx := RegExMatch(text , &quot;O)MoveR (?&lt;x&gt;-?\d+) (?&lt;y&gt;-?\d+)(?:`r`n)?Delay (?&lt;Delay&gt;-?\d+) ms&quot;, match, pEx ? pEx : 1) + StrLen(match.0)
	Arr.Insert(match)
return
F12::on := !on
	
#if on	
*~LButton::
Loop
	for i,k in Arr
	{
		if !GetKeyState(&quot;LButton&quot;,&quot;p&quot;)
			Return
		DllCall(&quot;mouse_event&quot;, uint, 1, int,  k.x, int,  k.y, uint, 0, int, 0)
		Sleep % k.Delay
		
	}
Return
#if</code></pre></div><p>P.S. Если я копирую в файл &#039;&#039;555.amc&#039;&#039; текст из первого поста то всё воспроизводится, хотя на вид ошибок&nbsp; нет всё идентично.</p>]]></content>
			<author>
				<name><![CDATA[Ядрён]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=30092</uri>
			</author>
			<updated>2022-10-21T19:43:19Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=155355#p155355</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Cчитать текст из файла и поместить в переменную]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=105695#p105695" />
			<content type="html"><![CDATA[<p>Может последнюю переменную не правильно RegEx видит.<br />Можно попробовать посмотреть что выдает скрипт в этих параметрах:</p><div class="codebox"><pre><code>*~vk5B::
FileSelectFile, SelectedFile, 24, , Загрузить макрос, *.amc

Arr := []

text := FileOpen(SelectedFile,&quot;r&quot;).Read()
While pEx := RegExMatch(text , &quot;O)MoveR (?&lt;x&gt;-?\d+) (?&lt;y&gt;-?\d+)(?:`r`n)?Delay (?&lt;Delay&gt;-?\d+)&quot;, match, pEx ? pEx : 1) + StrLen(match.0)
	Arr.Insert(match)
return
F12::on := !on
	
#if on	
*~LButton::
Loop
	for i,k in Arr
	{
		if !GetKeyState(&quot;LButton&quot;,&quot;p&quot;)
			Return
		;DllCall(&quot;mouse_event&quot;, uint, 1, int,  k.x, int,  k.y, uint, 0, int, 0)
		;Sleep % k.Delay
		ToolTip % &quot;index:`t&quot; i
		            .  &quot;`nX:`t&quot;	k.x
		            .  &quot;`nY:`t&quot; 	k.y
		            .  &quot;`nDelay:`t&quot;	k.Delay
		Sleep 500 ;--
	}
Return
#if</code></pre></div><p>Попробуй подобную строку заменить на эту<br /></p><div class="codebox"><pre><code>While pEx := RegExMatch(text , &quot;O)MoveR (?&lt;x&gt;-?\d+) (?&lt;y&gt;-?\d+)(?:`r`n)?Delay (?&lt;Delay&gt;-?\d+) ms&quot;, match, pEx ? pEx : 1) + StrLen(match.0)</code></pre></div>]]></content>
			<author>
				<name><![CDATA[yalanne]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=32850</uri>
			</author>
			<updated>2016-06-29T17:12:23Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=105695#p105695</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Cчитать текст из файла и поместить в переменную]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=105667#p105667" />
			<content type="html"><![CDATA[<p>Заметил кое что странное в работе скрипта . Когда загружаешь коротенький скрипт он его исполняет ну очень быстро(не так ка должно быть) , такое ощущение что с задержкой чтото не то.Хотя даже незнаю на что думать. Помогите разобраться пожалуйста.</p>]]></content>
			<author>
				<name><![CDATA[Ядрён]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=30092</uri>
			</author>
			<updated>2016-06-28T20:34:38Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=105667#p105667</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Cчитать текст из файла и поместить в переменную]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=105666#p105666" />
			<content type="html"><![CDATA[<p><strong>yalanne</strong> огромное вам спасибо за помощь.</p><p>Вот решил без Gui , додумался сам.</p><br /><div class="codebox"><pre><code>*~vk5B::
FileSelectFile, SelectedFile, 24, , Загрузить макрос, *.amc

text := FileOpen(SelectedFile,&quot;r&quot;).Read()</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Ядрён]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=30092</uri>
			</author>
			<updated>2016-06-28T19:32:39Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=105666#p105666</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Cчитать текст из файла и поместить в переменную]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=105623#p105623" />
			<content type="html"><![CDATA[<p>И ещё заметил чем длиннее файл тем медленнее работает.Начинает шустренько но на секунде 7-10 скорость выполнения значительно падает.</p>]]></content>
			<author>
				<name><![CDATA[Ядрён]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=30092</uri>
			</author>
			<updated>2016-06-27T21:59:10Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=105623#p105623</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Cчитать текст из файла и поместить в переменную]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=105622#p105622" />
			<content type="html"><![CDATA[<div class="quotebox"><blockquote><p><strong>yalanne пишет:</strong><br />А зачем gui с кнопками?</p></blockquote></div><p>Уважаемый <strong>yalanne</strong> таких файлов много (с разными параметрами) для мобильности что бы можно было быстро заменить один на другой. А можно вариант с Gui , нажал на кнопку открылось окно где можно выбрать файл.</p><p>Вот попробывал сделать выбор файла сам , но не получилось . Подскажите где ошибка.</p><div class="codebox"><pre><code>Open: 

Gui Submit, NoHide

FileSelectFile, SelectedFile, 1, , Загрузить макрос, *.amc

text := FileOpen(A_ScriptDir &quot;\%SelectedFile%.amc&quot;,&quot;r&quot;).Read()
 
Return</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Ядрён]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=30092</uri>
			</author>
			<updated>2016-06-27T20:14:42Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=105622#p105622</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Cчитать текст из файла и поместить в переменную]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=105602#p105602" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>Ядрён пишет:</cite><blockquote><p>Вот пример</p></blockquote></div><p> А что в самом скрипте должно происходить?<br />Если удерживается левая кнопка мыши(F12 вкл\выкл этой опции) то перемещаем мышь бесконечно по заданному пути, который есть в текстовом документе?<br />А зачем gui с кнопками?</p><br /><div class="codebox"><pre><code>Arr := []

text := FileOpen(A_ScriptDir &quot;\file.txt&quot;,&quot;r&quot;).Read()
While pEx := RegExMatch(text , &quot;O)MoveR (?&lt;x&gt;-?\d+) (?&lt;y&gt;-?\d+)(?:`r`n)?Delay (?&lt;Delay&gt;-?\d+)&quot;, match, pEx ? pEx : 1) + StrLen(match.0)
	Arr.Insert(match)
return
F12::on := !on
	
#if on	
*~LButton::
Loop
	for i,k in Arr
	{
		if !GetKeyState(&quot;LButton&quot;,&quot;p&quot;)
			Return
		DllCall(&quot;mouse_event&quot;, uint, 1, int,  k.x, int,  k.y, uint, 0, int, 0)
		Sleep % k.Delay
	}
Return
#if</code></pre></div><div class="fancy_spoiler_switcher"><div class="fancy_spoiler_switcher_header"><strong>+</strong>&nbsp;с комментами</div><div class="fancy_spoiler"><div class="codebox"><pre><code>; Создаем пустой массив.
; В нем будут хранится данные ввиде: Arr[index].x  Arr[index].y \ Arr[index].Delay
Arr := [] 

;Читаем файл file.txt и заносим в переменную text.
text := FileOpen(A_ScriptDir &quot;\file.txt&quot;,&quot;r&quot;).Read()

; Ищем нужные строки. Match уже идет здесь объектом.
; Цикл добавит  именные объекты x\y\delay в объект Arr под индексацию ввиде цифр.
While pEx := RegExMatch(text , &quot;O)MoveR (?&lt;x&gt;-?\d+) (?&lt;y&gt;-?\d+)(?:`r`n)?Delay (?&lt;Delay&gt;-?\d+)&quot;, match, pEx ? pEx : 1) + StrLen(match.0)
	Arr.Insert(match)

; конец. Ждем нажатий кнопок.
return

; Переключение режима.
F12::on := !on
	
#if on	
*~LButton::
Loop
; цикл для массивов.
	for i,k in Arr
	{
		if !GetKeyState(&quot;LButton&quot;,&quot;p&quot;)
			Return
		DllCall(&quot;mouse_event&quot;, uint, 1, int,  k.x, int,  k.y, uint, 0, int, 0)
		Sleep % k.Delay
	}
Return
#if</code></pre></div></div></div>]]></content>
			<author>
				<name><![CDATA[yalanne]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=32850</uri>
			</author>
			<updated>2016-06-27T13:15:34Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=105602#p105602</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Cчитать текст из файла и поместить в переменную]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=105596#p105596" />
			<content type="html"><![CDATA[<p>Воспользоваться ini-файлом?</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2016-06-27T11:41:23Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=105596#p105596</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[AHK: Cчитать текст из файла и поместить в переменную]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=105595#p105595" />
			<content type="html"><![CDATA[<p>Доброго времени суток. Подскажите пожалуйста как можно считать текст из файла и поместить в переменную , но не весь текст а после определённого слова &quot;MoveR&quot; и &quot;Delay&quot; . После слова &quot;MoveR&quot; стоят две цифры первая цифра это значение для координаты &quot;x&quot; , вторая цифра для координаты &quot;y&quot;, Delay - задержка. </p><p>Сам файл.</p><div class="codebox"><pre><code>MoveR -11 8
Delay 32 ms
MoveR -6 4
Delay 32 ms
IfKey 1 0 1
MoveR -2 2
Delay 32 ms
MoveR -1 1
Delay 32 ms
MoveR 0 0
Delay 32 ms
IfKey 1 0 1
MoveR -18 15
Delay 32 ms
MoveR -1 2
Delay 32 ms
MoveR 0 0
Delay 32 ms
IfKey 1 0 1
MoveR -19 -8
Delay 32 ms
MoveR -1 -2
Delay 32 ms</code></pre></div><p>Вот пример , но я не знаю как считать из файла и заполнить переменные &quot;x&quot; , &quot;y&quot; , &quot;Delay&quot; .</p><div class="codebox"><pre><code>#NoEnv
#SingleInstance force
#Persistent
#NoEnv
SendMode Input
SetBatchLines, -1
#MaxHotkeysPerInterval
#HotkeyInterval, -1

Gui, Color, 9CEE90

Gui, Font, s11 Bold, Cambria

Gui, Add, Button, x20 y90 w42 h20 gOpen, Open

Gui, Add, Button, x108 y90 w42 h20 gOK, OK

Gui, Show, x557 y130 h171 w255
Return

OK:  
Gui Submit, NoHide
x := Arr[A_Index*2-1]
y := Arr[A_Index*2]
Delay := Arr[A_Index*3]
Return

Open: 
Return

#If on
*~Lbutton::
Loop
   Loop % Arr.MaxIndex() &gt;&gt; 1
   {
      if !GetKeyState(&quot;Lbutton&quot;, &quot;P&quot;)
         Break 2
      
DllCall(&quot;mouse_event&quot;, uint, 1, int,  Arr[A_Index*2-1], int,  Arr[A_Index*2], uint, 0, int, 0)
      Sleep, Arr[A_Index*3]
   }
Return
#If

F12:: on := !on
GuiClose:
ExitApp</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Ядрён]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=30092</uri>
			</author>
			<updated>2016-06-27T11:34:43Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=105595#p105595</id>
		</entry>
</feed>
