<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Серый форум &mdash; AHK: Cчитать текст из файла и поместить в переменную]]></title>
		<link>https://forum.script-coding.com/viewtopic.php?id=11767</link>
		<atom:link href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=11767&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[Недавние сообщения в теме «AHK: Cчитать текст из файла и поместить в переменную».]]></description>
		<lastBuildDate>Sat, 29 Oct 2022 11:07:38 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: AHK: Cчитать текст из файла и поместить в переменную]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=155470#p155470</link>
			<description><![CDATA[<p><strong>teadrinker</strong> Понял.</p>]]></description>
			<author><![CDATA[null@example.com (Ядрён)]]></author>
			<pubDate>Sat, 29 Oct 2022 11:07:38 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=155470#p155470</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Cчитать текст из файла и поместить в переменную]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=155466#p155466</link>
			<description><![CDATA[<p><strong>Ядрён</strong>, для тем по играм есть своя ветка.</p>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Sat, 29 Oct 2022 10:48:31 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=155466#p155466</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Cчитать текст из файла и поместить в переменную]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=155460#p155460</link>
			<description><![CDATA[<p><strong>teadrinker</strong> Спвсибо!</p>]]></description>
			<author><![CDATA[null@example.com (Ядрён)]]></author>
			<pubDate>Sat, 29 Oct 2022 10:41:02 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=155460#p155460</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Cчитать текст из файла и поместить в переменную]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=155453#p155453</link>
			<description><![CDATA[<p>Спасибо разобрался, символ перевода строки (`n) был прописан с ошибкой.</p>]]></description>
			<author><![CDATA[null@example.com (Ядрён)]]></author>
			<pubDate>Sat, 29 Oct 2022 10:29:54 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=155453#p155453</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Cчитать текст из файла и поместить в переменную]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=155435#p155435</link>
			<description><![CDATA[<p><strong>Ядрён</strong><br />А я бы Loop, Read использовал бы. Ну каждому своё.</p>]]></description>
			<author><![CDATA[null@example.com (andrey.a.polyakov.b2c)]]></author>
			<pubDate>Fri, 28 Oct 2022 18:51:05 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=155435#p155435</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Cчитать текст из файла и поместить в переменную]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=155355#p155355</link>
			<description><![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>]]></description>
			<author><![CDATA[null@example.com (Ядрён)]]></author>
			<pubDate>Fri, 21 Oct 2022 19:43:19 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=155355#p155355</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Cчитать текст из файла и поместить в переменную]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=105695#p105695</link>
			<description><![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>]]></description>
			<author><![CDATA[null@example.com (yalanne)]]></author>
			<pubDate>Wed, 29 Jun 2016 17:12:23 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=105695#p105695</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Cчитать текст из файла и поместить в переменную]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=105667#p105667</link>
			<description><![CDATA[<p>Заметил кое что странное в работе скрипта . Когда загружаешь коротенький скрипт он его исполняет ну очень быстро(не так ка должно быть) , такое ощущение что с задержкой чтото не то.Хотя даже незнаю на что думать. Помогите разобраться пожалуйста.</p>]]></description>
			<author><![CDATA[null@example.com (Ядрён)]]></author>
			<pubDate>Tue, 28 Jun 2016 20:34:38 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=105667#p105667</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Cчитать текст из файла и поместить в переменную]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=105666#p105666</link>
			<description><![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>]]></description>
			<author><![CDATA[null@example.com (Ядрён)]]></author>
			<pubDate>Tue, 28 Jun 2016 19:32:39 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=105666#p105666</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Cчитать текст из файла и поместить в переменную]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=105623#p105623</link>
			<description><![CDATA[<p>И ещё заметил чем длиннее файл тем медленнее работает.Начинает шустренько но на секунде 7-10 скорость выполнения значительно падает.</p>]]></description>
			<author><![CDATA[null@example.com (Ядрён)]]></author>
			<pubDate>Mon, 27 Jun 2016 21:59:10 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=105623#p105623</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Cчитать текст из файла и поместить в переменную]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=105622#p105622</link>
			<description><![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>]]></description>
			<author><![CDATA[null@example.com (Ядрён)]]></author>
			<pubDate>Mon, 27 Jun 2016 20:14:42 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=105622#p105622</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Cчитать текст из файла и поместить в переменную]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=105602#p105602</link>
			<description><![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>]]></description>
			<author><![CDATA[null@example.com (yalanne)]]></author>
			<pubDate>Mon, 27 Jun 2016 13:15:34 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=105602#p105602</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Cчитать текст из файла и поместить в переменную]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=105596#p105596</link>
			<description><![CDATA[<p>Воспользоваться ini-файлом?</p>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Mon, 27 Jun 2016 11:41:23 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=105596#p105596</guid>
		</item>
		<item>
			<title><![CDATA[AHK: Cчитать текст из файла и поместить в переменную]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=105595#p105595</link>
			<description><![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>]]></description>
			<author><![CDATA[null@example.com (Ядрён)]]></author>
			<pubDate>Mon, 27 Jun 2016 11:34:43 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=105595#p105595</guid>
		</item>
	</channel>
</rss>
