<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Серый форум &mdash; AHK: eval() hotstrings]]></title>
		<link>https://forum.script-coding.com/viewtopic.php?id=9377</link>
		<atom:link href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=9377&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[Недавние сообщения в теме «AHK: eval() hotstrings».]]></description>
		<lastBuildDate>Sat, 04 Oct 2014 19:38:04 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: AHK: eval() hotstrings]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=87017#p87017</link>
			<description><![CDATA[<p>Да-с, память имеет свойство искажаться. Извините, что ввёл в заблуждение с <em>Include</em> в случае со скомпилированным скриптом.</p>]]></description>
			<author><![CDATA[null@example.com (ypppu)]]></author>
			<pubDate>Sat, 04 Oct 2014 19:38:04 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=87017#p87017</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: eval() hotstrings]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=87015#p87015</link>
			<description><![CDATA[<p>Тоже не понял идею с Include-файлом, т.к. после его изменения необходимо все равно пересобрать exe-файл.</p>]]></description>
			<author><![CDATA[null@example.com (Irbis)]]></author>
			<pubDate>Sat, 04 Oct 2014 15:41:18 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=87015#p87015</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: eval() hotstrings]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=87014#p87014</link>
			<description><![CDATA[<div class="quotebox"><cite>Irbis пишет:</cite><blockquote><p>На форуме имеются примеры записи в память процесса и поиска в памяти процесса. Можно попробовать сделать в конце скрипта метку, например Dyn_Proc:&lt;<em>много пробелов для выделения памяти</em>&gt;, найти начало пустого места и динамически менять его на нужный код, затем вызывать на исполнение командой <strong>GoSub Dyn_proc</strong>.</p><p>По крайней мере, так должно работать в теории.</p></blockquote></div><p>Огромное спасибо. <br />Вы предложили самый реальный вариант решения моей задачи.<br />Ещё бы как-то научиться сохранять по завершении работы программы изменившийся код в оперативной памяти на диск - было бы вообще круто.<br />Т.е. получился бы самомодифицирующийся экзешник</p>]]></description>
			<author><![CDATA[null@example.com (Доктор ТуамОсес)]]></author>
			<pubDate>Sat, 04 Oct 2014 15:39:14 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=87014#p87014</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: eval() hotstrings]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=87013#p87013</link>
			<description><![CDATA[<div class="quotebox"><cite>Irbis пишет:</cite><blockquote><p>Скомпилированный скрипт в любом случае содержит в себе текстовый вариант скрипта + интерпретатор, который точно так же построчно обрабатывает исходный скрипт, загруженный в память.</p></blockquote></div><p>Спасибо за ответ.<br />Это очень существенная информация для моих целей.<br />И я раньше этого не знал. <br />Но при компиляции в этот экзешник и тексты инклудов запихиваются.Так?<br />Так что выше предложенный вариант с инклудами ещё одного уважаемого участника тут не прокатит?<br />Потому что после того как я изменю инклуд мне придётся заново компилить весь проект.</p>]]></description>
			<author><![CDATA[null@example.com (Доктор ТуамОсес)]]></author>
			<pubDate>Sat, 04 Oct 2014 15:36:18 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=87013#p87013</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: eval() hotstrings]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=87012#p87012</link>
			<description><![CDATA[<p>Скомпилированный скрипт в любом случае содержит в себе текстовый вариант скрипта + интерпретатор, который точно так же построчно обрабатывает исходный скрипт, загруженный в память.</p><p>На форуме имеются примеры записи в память процесса и поиска в памяти процесса. Можно попробовать сделать в конце скрипта метку, например Dyn_Proc:&lt;<em>много пробелов для выделения памяти</em>&gt;, найти начало пустого места и динамически менять его на нужный код, затем вызывать на исполнение командой <strong>GoSub Dyn_proc</strong>.</p><p>По крайней мере, так должно работать в теории.</p>]]></description>
			<author><![CDATA[null@example.com (Irbis)]]></author>
			<pubDate>Sat, 04 Oct 2014 14:33:00 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=87012#p87012</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: eval() hotstrings]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=87007#p87007</link>
			<description><![CDATA[<div class="quotebox"><cite>ypppu пишет:</cite><blockquote><p>Как вариант -&nbsp; в процессе работы скрипта вписывать нужные строки автозамены в файл скрипта и тут же перезапускать его.</p></blockquote></div><p>Спасибо за вариант, только я хотел бы &quot;править код на лету&quot; без необходимости перезапускать программу с самого начала</p><br /><div class="quotebox"><cite>ypppu пишет:</cite><blockquote><p>В случае со скомпилированным скриптом - прописать в коде скрипта файл-Include и вписывать новый код в Include-файл.</p></blockquote></div><p>Не очень понял. Разве инклуд при компиляции основного файла тоже не компилится в общий экзешник?<br />Вы хотите сказать, что компилится только основной файл, а инклуды так и остаются в виде &quot;сырого кода&quot;?</p>]]></description>
			<author><![CDATA[null@example.com (Доктор ТуамОсес)]]></author>
			<pubDate>Sat, 04 Oct 2014 09:49:25 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=87007#p87007</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: eval() hotstrings]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=87006#p87006</link>
			<description><![CDATA[<p>Как вариант -&nbsp; в процессе работы скрипта вписывать нужные строки автозамены в файл скрипта и тут же перезапускать его.<br />В случае со скомпилированным скриптом - прописать в коде скрипта файл-Include и вписывать новый код в Include-файл.</p>]]></description>
			<author><![CDATA[null@example.com (ypppu)]]></author>
			<pubDate>Sat, 04 Oct 2014 09:23:00 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=87006#p87006</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: eval() hotstrings]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=87004#p87004</link>
			<description><![CDATA[<p>Нельзя.</p>]]></description>
			<author><![CDATA[null@example.com (YMP)]]></author>
			<pubDate>Sat, 04 Oct 2014 06:35:48 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=87004#p87004</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: eval() hotstrings]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=87003#p87003</link>
			<description><![CDATA[<div class="quotebox"><cite>Drugoy пишет:</cite><blockquote><p>Хочется скрипт, который бы умел читать содержимое внешнего файла и использовать записанные в этом файле слова и сопоставленные им фразы, как условия и результаты для hotstring&#039;ов.<br />Т.е. если файл содержит<br /></p><div class="codebox"><pre><code>WOT|Web of Trust
MzFx|Mozilla Firefox
B.Y.O.B|bring your own booze</code></pre></div><p>то скрипт должен срабатывать так же, как если бы он содержал<br /></p><div class="codebox"><pre><code>::WOT::
msgbox Web of Trust
Return
::MzFx::
msgbox Mozilla Firefox
Return
::B.Y.O.B::
msgbox bring your own booze
Return</code></pre></div></blockquote></div><p>У меня похожая задача (поэтому не стал создавать отдельную тему).<br />Мне хочется строки использовать как исходный код.<br />eval позволяет указать интерпретатору, что строковая переменная является выражением.<br />А мне хотелось бы большего: указать интерпретатору, что строковая переменная является куском кода на AHK, который нужно выполнить.</p><p>Господа! Можно такое реализовать на языке программирования &quot;AutoHotKey&quot;?</p>]]></description>
			<author><![CDATA[null@example.com (Доктор ТуамОсес)]]></author>
			<pubDate>Sat, 04 Oct 2014 06:27:33 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=87003#p87003</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: eval() hotstrings]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=83146#p83146</link>
			<description><![CDATA[<p>nvm</p>]]></description>
			<author><![CDATA[null@example.com (Drugoy)]]></author>
			<pubDate>Tue, 20 May 2014 13:35:54 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=83146#p83146</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: eval() hotstrings]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=82320#p82320</link>
			<description><![CDATA[<p>а как выставить endchar&#039;ом Enter но так, чтобы он не отсылался в окно, куда набирается хотстринг?</p>]]></description>
			<author><![CDATA[null@example.com (Drugoy)]]></author>
			<pubDate>Sat, 26 Apr 2014 18:23:32 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=82320#p82320</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: eval() hotstrings]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=82269#p82269</link>
			<description><![CDATA[<div class="quotebox"><cite>Irbis пишет:</cite><blockquote><div class="codebox"><pre><code>#Include hotstring.ahk

Array := {}
Loop, Read, %A_ScriptDir%\Hotstrings.ini
{
   tmp := StrSplit(A_LoopReadLine,&quot;|&quot;)
   Array.Insert(RegExReplace(tmp[1], &quot;[\i\),\\n]&quot;), tmp[2])
   Hotstring(tmp[1],&quot;MsgBox&quot;,3)
}
return

MsgBox:
MsgBox % Array[RegExReplace($, &quot;\n&quot;)]
Return
</code></pre></div></blockquote></div><p>В случае если в hotstrings.ini идёт любая из этих записей<br /></p><div class="codebox"><pre><code>anvir`|C:\Soft\Portable soft\AnvirTaskManager\AnVir.exe
vir`|C:\Soft\Portable soft\AnvirTaskManager\AnVir.exe</code></pre></div><p>она портится этой строкой<br /></p><div class="codebox"><pre><code>Array.Insert(RegExReplace(tmp[1], &quot;[\i\),\\n]&quot;), tmp[2])</code></pre></div><p>так, что из левой части выпадает i:<br />hotstring&#039;и добавляются верные, но в массив они попадают как <span class="bbu">anvr`</span> и <span class="bbu">vr`</span>.<br />Причём хотстринг срабатывает именно при наборе <span class="bbu">anvir`</span> и <span class="bbu">vir`</span>, но т.к. в массиве этих значений нет, то скрипт не может и вызвать программу по пути указанному в правой части строки в hotstrings.ini<br />Проверить это можно добавив строку <br /></p><div class="codebox"><pre><code>msgbox % &quot;RegExReplace(tmp[1], &quot;&quot;[\i\),\\n]&quot;&quot;): &#039;&quot; RegExReplace(tmp[1], &quot;[\i\),`]&quot;) &quot;&#039;&quot;</code></pre></div><p>после или перед <span class="bbu">Array.Insert</span>.</p><p>Конечно же, был неправильно составлен RegEx needle. Должно быть что-то типа &quot;^i\)|\\n$&quot;. Внутри квадратных скобок перечисляются отдельные символы, они не составляют последовательностей.</p>]]></description>
			<author><![CDATA[null@example.com (Drugoy)]]></author>
			<pubDate>Thu, 24 Apr 2014 19:34:56 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=82269#p82269</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: eval() hotstrings]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=81636#p81636</link>
			<description><![CDATA[<p>спасибо, проблему решил<br /></p><div class="fancy_spoiler_switcher"><div class="fancy_spoiler_switcher_header" data-lang-open="открыть спойлер" data-lang-close="скрыть спойлер"><strong>+</strong>&nbsp;открыть спойлер</div><div class="fancy_spoiler"><div class="codebox"><pre><code>#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
#SingleInstance, Force
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
; #Include Hotstring.ahk
#MaxThreadsPerHotkey, 20

Global extractTo := A_Temp &quot;\executor&quot;    ; Path where to extract archives&#039; contents to.

Array := {}
Loop, Read, %A_ScriptDir%\Hotstrings.ini    ; This files contents consist of lines that each consists of two parts separated with a pipe. Left part is the hotstring trigger text and the right part is the full path.
{
    tmp := StrSplit(A_LoopReadLine, &quot;|&quot;)
    If (tmp[1] == &quot;archiver&quot;)    ; If the left part of a line is &quot;archiver&quot;.
        Global archiver := tmp[2]    ; Then store the path from the right part of that line into a variable &#039;archiver&#039; that will later be used for reaching files inside of archives.
    Array.Insert(RegExReplace(tmp[1], &quot;[\i\),`]&quot;), tmp[2])
    Hotstring(tmp[1], &quot;subRoutine&quot;, 3)
}
Return

#IfWinActive, ahk_exe explorer.exe ahk_class #32770

subRoutine:
    mainFunc(Array[$])
Return

mainFunc(input)
{
    ControlGetFocus, activeControl, A
    If (activeControl == &quot;Edit1&quot;)    ; Win+R window: &quot;Execute&quot; (or &quot;Выполнить&quot; in Ru OS locale).
    {
        WinClose    ; Close the &quot;Execute&quot; (or &quot;Выполнить&quot; in Ru OS locale) window.
        IfInString, input, !    ; Paths with &quot;!&quot; are the ones pointing to the files inside archives.
; Example path to an executable inside an archive: C:\Test.rar!subfolder\runme.exe
        {
            partialPath := StrSplit(input, &quot;!&quot;)    ; partialPath[1] contains the path to the archive. partialPath[2] contains the relative path to the executable withing the archive (where root is the archive itself).
            archiveName := SubStr(partialPath[1], InStr(partialPath[1], &quot;\&quot;,, 0), InStr(partialPath[1], &quot;.&quot;,, 0) - InStr(partialPath[1], &quot;\&quot;,, 0))    ; Archive&#039;s name (without extension) will be used to name the temporary folder where it will get unpacked to.
            RunWait, % &quot;&quot;&quot;&quot; archiver &quot;&quot;&quot; x &quot;&quot;&quot; partialPath[1] &quot;&quot;&quot; -aoa -y -o&quot;&quot;&quot; extractTo archiveName &quot;&quot;&quot;&quot;,, Hide    ; Use the archiver to unpack the files.
            Global runThis := extractTo archiveName &quot;\&quot; partialPath[2]
            Global removeThis := extractTo archiveName
            waitAndRemove(runThis, removeThis)
        }
        Else    ; The path points to a file outside archive.
            Run, %input%
    }
    ListLines
}

waitAndRemove(runWait, fileRemoveDir)
{
    RunWait, %runWait%
    FileRemoveDir, %fileRemoveDir%, 1    ; Remove the unpacked stuff after it got closed.
}</code></pre></div></div></div>]]></description>
			<author><![CDATA[null@example.com (Drugoy)]]></author>
			<pubDate>Thu, 10 Apr 2014 15:32:05 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=81636#p81636</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: eval() hotstrings]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=81624#p81624</link>
			<description><![CDATA[<div class="quotebox"><blockquote><p>Но так почему-то не создаются новые псевдо-thread&#039;ы</p></blockquote></div><p>Settimer не создаёт новые псевдо-треды при вызове, а ставит в очередь вызов метки. Если Settimer для текущей метки уже был вызван - вызов смещается в очереди (или нет, в зависимоти от параметров вызова).</p><p>Чтобы создать два асинхронных потока нужно иметь две метки и выполнить settimer два раза. Тот поток, который создан ранее начнёт выполнение как только основной поток использует sleep или выполнит все операции, второй асинхронный поток начнёт выполнение как только первый вызовет sleep (при условии что приоритеты потоков при вызове settimer указаны одинаковые)</p><p>Под sleep подразумевается режим ожидания интерпретатора.</p><p>Ну и пример для самых маленьких:<br /></p><div class="codebox"><pre><code>#Persistent

SetTimer 1, -1
SetTimer 1, -300
return

1:
    MsgBox
    return

Esc::ExitApp</code></pre></div><div class="codebox"><pre><code>#Persistent

SetTimer 1, -1
SetTimer 2, -300
return

2:
1:
    MsgBox
    return

Esc::ExitApp</code></pre></div><p>В первом случае 1 msgbox через 300 мс, во втором - 2</p><br /><div class="codebox"><pre><code>            Global runThis := extractTo archiveName &quot;\&quot; partialPath[2]
            Global removeThis := extractTo archiveName
            SetTimer, timer, -1</code></pre></div><p>Это имеет смысл если ты уверен, что следующий вызов mainfunc произойдёт гарантированно после того как waitAndRemove возьмёт из этих переменных&nbsp; значения указанные в предыдущем вызове mainfunc.&nbsp; Если такой уверенности нет, то нужно организовать очередь вызовов - mainfunc пишет в очередь нужные параметры и для каждой записи вызывает асинхронный waitAndRemove, waitAndRemove читает и удаляет из очереди взятые на исполнение параметры (когда угодно читает, и удаляет, но гаратированно не теряет параметры в случае если между вызоывами mainfunc не удалось выполнить асинронный waitAndRemove)</p>]]></description>
			<author><![CDATA[null@example.com (bWRmeA)]]></author>
			<pubDate>Thu, 10 Apr 2014 09:36:29 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=81624#p81624</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: eval() hotstrings]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=81614#p81614</link>
			<description><![CDATA[<p>Я не знаю стоит ли создавать для этого новую тему или писать сюда, но т.к. всё-таки проблема связана и с этой темой - то решил написать сюда.</p><p>Мой скрипт мутировал в такое:<br /></p><div class="codebox"><pre><code>#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
#SingleInstance, Force
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
; #Include Hotstring.ahk

Global extractTo := A_Temp &quot;\executor&quot;  ; Path where to extract archives&#039; contents to.

Array := {}
Loop, Read, %A_ScriptDir%\Hotstrings.ini    ; This files contents consist of lines that each consists of two parts separated with a pipe. Left part is the hotstring trigger text and the right part is the full path.
{
    tmp := StrSplit(A_LoopReadLine, &quot;|&quot;)
    If (tmp[1] == &quot;archiver&quot;)   ; If the left part of a line is &quot;archiver&quot;.
        Global archiver := tmp[2]   ; Then store the path from the right part of that line into a variable &#039;archiver&#039; that will later be used for reaching files inside of archives.
    Array.Insert(RegExReplace(tmp[1], &quot;[\i\),`]&quot;), tmp[2])
    Hotstring(tmp[1], &quot;subRoutine&quot;, 3)
}
Return

#IfWinActive, ahk_exe explorer.exe ahk_class #32770

subRoutine:
    mainFunc(Array[$])
Return

mainFunc(input)
{
    ControlGetFocus, activeControl, A
    If (activeControl == &quot;Edit1&quot;)   ; Win+R window: &quot;Execute&quot; (or &quot;Выполнить&quot; in Ru OS locale).
    {
        WinClose    ; Close the &quot;Execute&quot; (or &quot;Выполнить&quot; in Ru OS locale) window.
        IfInString, input, !    ; Paths with &quot;!&quot; are the ones pointing to the files inside archives.
; Example path to an executable inside an archive: C:\Test.rar!subfolder\runme.exe
        {
            partialPath := StrSplit(input, &quot;!&quot;) ; partialPath[1] contains the path to the archive. partialPath[2] contains the relative path to the executable withing the archive (where root is the archive itself).
            archiveName := SubStr(partialPath[1], InStr(partialPath[1], &quot;\&quot;,, 0), InStr(partialPath[1], &quot;.&quot;,, 0) - InStr(partialPath[1], &quot;\&quot;,, 0))  ; Archive&#039;s name (without extension) will be used to name the temporary folder where it will get unpacked to.
            RunWait, % &quot;&quot;&quot;&quot; archiver &quot;&quot;&quot; x &quot;&quot;&quot; partialPath[1] &quot;&quot;&quot; -aoa -y -o&quot;&quot;&quot; extractTo archiveName &quot;&quot;&quot;&quot;,, Hide   ; Use the archiver to unpack the files.
            RunWait, % extractTo archiveName &quot;\&quot; partialPath[2] ; Run the needed executable from the unpacked files.
            FileRemoveDir, % extractTo archiveName, 1   ; Remove the unpacked stuff after it got closed.
        }
        Else    ; The path points to a file outside archive.
            Run, % Array[RegExReplace($, &quot;`&quot;)]
    }
}</code></pre></div><p>Он позволяет запускать программы, в том числе программы внутри архивов по заранее заданным alias&#039;ам для этих программ.<br />Alias&#039;ы хранятся во внешнем файле %A_ScriptDir%\Hotstrings.ini<br />Содержимое этого файла должно выглядеть вот так:<br /></p><div class="codebox"><pre><code>archiver|C:\Program files\7-zip\7z.exe
7z`|C:\Program files\7-zip\7zFM.exe
7zip`|C:\Program files\7-zip\7zFM.exe
7-zip`|C:\Program files\7-zip\7zFM.exe
rar`|C:\Program files\WinRar\winrar.exe
unrar`|C:\Program files\WinRar\winrar.exe
winrar`|C:\Program files\WinRar\winrar.exe
ape`|C:\Soft\Utils\AppPathsEditor.zip!ape.exe
apppaths`|C:\Soft\Utils\AppPathsEditor.zip!ape.exe
junction`|C:\Soft\Utils\Junction.zip!Junction.exe
junctions`|C:\Soft\Utils\Junction.zip!Junction.exe
junc`|C:\Soft\Utils\Junction.zip!Junction.exe
junk`|C:\Soft\Utils\Junction.zip!Junction.exe
switcherx`|C:\Soft\Utils\Switcherx.rar!SwitcherX\SwitcherX.exe</code></pre></div><p>Пользоваться скриптом так: запустить его, нажать Win+R (откроется окно &quot;выполнить&quot;), туда вбить &quot;ape`&quot; (без кавычек, но со штрихом) и откроется ape.exe из архива C:\Soft\Utils\AppPathsEditor.zip</p><p>Штука в том, что если была попытка запустить файл из архива - то архив сначала распаковывается (используя архиватор, путь к которому задаётся внутри hotstrings.ini в alias&#039;е &quot;archiver&quot;), затем RunWait&#039;ом открывается нужный исполняемый файл. RunWait нужен для того, чтобы по закрытии программы были удалены все распакованные из архива файлы. Т.е. реализована чистка за собой.<br />Но проблема в том, что не получается одновременно запустить 2 программы, если они обе заархивированы.<br />Не получается как раз из-за RunWait&#039;а.</p><p>Как решить проблему через SetTimer?<br />Пробовал вот так<br /></p><div class="codebox"><pre><code>#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
#SingleInstance, Force
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
; #Include Hotstring.ahk

Global extractTo := A_Temp &quot;\executor&quot;    ; Path where to extract archives&#039; contents to.

Array := {}
Loop, Read, %A_ScriptDir%\Hotstrings.ini    ; This files contents consist of lines that each consists of two parts separated with a pipe. Left part is the hotstring trigger text and the right part is the full path.
{
    tmp := StrSplit(A_LoopReadLine, &quot;|&quot;)
    If (tmp[1] == &quot;archiver&quot;)    ; If the left part of a line is &quot;archiver&quot;.
        Global archiver := tmp[2]    ; Then store the path from the right part of that line into a variable &#039;archiver&#039; that will later be used for reaching files inside of archives.
    Array.Insert(RegExReplace(tmp[1], &quot;[\i\),`]&quot;), tmp[2])
    Hotstring(tmp[1], &quot;subRoutine&quot;, 3)
}
Return

#IfWinActive, ahk_exe explorer.exe ahk_class #32770

subRoutine:
    mainFunc(Array[$])
Return

timer:
        waitAndRemove(runThis, removeThis)
Return


mainFunc(input)
{
    ControlGetFocus, activeControl, A
    If (activeControl == &quot;Edit1&quot;)    ; Win+R window: &quot;Execute&quot; (or &quot;Выполнить&quot; in Ru OS locale).
    {
        WinClose    ; Close the &quot;Execute&quot; (or &quot;Выполнить&quot; in Ru OS locale) window.
        IfInString, input, !    ; Paths with &quot;!&quot; are the ones pointing to the files inside archives.
; Example path to an executable inside an archive: C:\Test.rar!subfolder\runme.exe
        {
            partialPath := StrSplit(input, &quot;!&quot;)    ; partialPath[1] contains the path to the archive. partialPath[2] contains the relative path to the executable withing the archive (where root is the archive itself).
            archiveName := SubStr(partialPath[1], InStr(partialPath[1], &quot;\&quot;,, 0), InStr(partialPath[1], &quot;.&quot;,, 0) - InStr(partialPath[1], &quot;\&quot;,, 0))    ; Archive&#039;s name (without extension) will be used to name the temporary folder where it will get unpacked to.
            RunWait, % &quot;&quot;&quot;&quot; archiver &quot;&quot;&quot; x &quot;&quot;&quot; partialPath[1] &quot;&quot;&quot; -aoa -y -o&quot;&quot;&quot; extractTo archiveName &quot;&quot;&quot;&quot;,, Hide    ; Use the archiver to unpack the files.
            Global runThis := extractTo archiveName &quot;\&quot; partialPath[2]
            Global removeThis := extractTo archiveName
            SetTimer, timer, -1
            ; RunWait, % extractTo archiveName &quot;\&quot; partialPath[2]    ; Run the needed executable from the unpacked files.
            ; FileRemoveDir, % extractTo archiveName, 1    ; Remove the unpacked stuff after it got closed.
        }
        Else    ; The path points to a file outside archive.
            Run, %input%
    }
    ListLines
}

waitAndRemove(runWait, fileRemoveDir)
{
msgbox runWait: &#039;%runWait%&#039;`nfileRemoveDir: &#039;%fileRemoveDir%&#039;`n
    RunWait, %runWait%
    FileRemoveDir, %fileRemoveDir%, 1    ; Remove the unpacked stuff after it got closed.
}</code></pre></div><p>Но так почему-то не создаются новые псевдо-thread&#039;ы и скрипт перестаёт реагировать на хотстринги когда висит на RunWait&#039;е.</p><p>Второй вариант решения проблемы мне видится в том, чтобы создать массив PID&#039;ов и сопоставленных им имён папок (куда были распакованы архивы), которые проверять settimer&#039;ом на жизненность и удалять соответствующую папку, если PID умер.<br />Вариант с массивами пока не рассматривается как решение (хочется всё-таки получше с thread&#039;ами разобраться).</p>]]></description>
			<author><![CDATA[null@example.com (Drugoy)]]></author>
			<pubDate>Wed, 09 Apr 2014 23:56:31 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=81614#p81614</guid>
		</item>
	</channel>
</rss>
