<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Серый форум &mdash; AHK: Выполнение команды из переменной]]></title>
		<link>https://forum.script-coding.com/viewtopic.php?id=7712</link>
		<atom:link href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=7712&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[Недавние сообщения в теме «AHK: Выполнение команды из переменной».]]></description>
		<lastBuildDate>Sat, 20 Oct 2012 12:57:09 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: AHK: Выполнение команды из переменной]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=64887#p64887</link>
			<description><![CDATA[<p>Тогда так:<br /></p><div class="codebox"><pre><code>DynaRun(tempScript, streamName = &quot;&quot;)
{
    (streamName = &quot;&quot; &amp;&amp; streamName := &quot;AHK_&quot; . A_TickCount)
    streamName := &quot;\\.\&quot; . A_ScriptFullPath . &quot;:&quot; . streamName
    stream := FileOpen(streamName, &quot;rw&quot;)
    stream.Write(tempScript)
    stream.Close()

    Run, % A_AhkPath . &quot; &quot;&quot;&quot; . streamName . &quot;&quot;&quot;&quot;,, UseErrorLevel HIDE, processID
    if ErrorLevel
        MsgBox, 262144, ERROR, % &quot;Could not open file:`n &quot;&quot;&quot; . streamName . &quot;&quot;&quot;&quot;

    Sleep 50 ; иначе скрипт не успевает загрузится из потока
    DllCall(&quot;DeleteFile&quot;, &quot;Str&quot;, streamName, &quot;UInt&quot;)

    return processID
}

var := &quot;msgbox % A_ScriptFullPath&quot;
DynaRun(var)
msgbox % A_ScriptFullPath</code></pre></div><p>Странно, что <strong>FileDelete, file:stream</strong> не работает как ожидается.</p>]]></description>
			<author><![CDATA[null@example.com (creature.ws)]]></author>
			<pubDate>Sat, 20 Oct 2012 12:57:09 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=64887#p64887</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Выполнение команды из переменной]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=64886#p64886</link>
			<description><![CDATA[<p>Для создания/удаления/записи/чтения из потоков применяются те же WinAPI функции, что и для обычных файлов.</p>]]></description>
			<author><![CDATA[null@example.com (Александр_)]]></author>
			<pubDate>Sat, 20 Oct 2012 11:23:57 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=64886#p64886</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Выполнение команды из переменной]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=64880#p64880</link>
			<description><![CDATA[<p>Запись в ntfs-поток — хорошая альтернатива. К сожалению, не знаю способа удаления ntfs-потока без удаления «родительского» файла.</p>]]></description>
			<author><![CDATA[null@example.com (creature.ws)]]></author>
			<pubDate>Sat, 20 Oct 2012 10:59:01 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=64880#p64880</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Выполнение команды из переменной]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=64877#p64877</link>
			<description><![CDATA[<div class="quotebox"><cite>creature.ws пишет:</cite><blockquote><p>Без лишних записей на диск, видимо. Функция взята с оф. форума и слегка модифицирована.</p></blockquote></div><p>Можно пометить файл как временный, тогда мусора на винчестере не будет(а на NTFS можно ещё и в поток к своему скрипту записать). Пайпы нужны для взаимодействия потоков внутри рабочей группы/домена, по сути это всё равно, что использовать сокеты.</p>]]></description>
			<author><![CDATA[null@example.com (Александр_)]]></author>
			<pubDate>Sat, 20 Oct 2012 09:49:07 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=64877#p64877</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Выполнение команды из переменной]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=64876#p64876</link>
			<description><![CDATA[<p>Без лишних записей на диск, видимо. Функция взята с оф. форума и слегка модифицирована.</p>]]></description>
			<author><![CDATA[null@example.com (creature.ws)]]></author>
			<pubDate>Sat, 20 Oct 2012 09:36:55 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=64876#p64876</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Выполнение команды из переменной]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=64875#p64875</link>
			<description><![CDATA[<p><strong>creature.ws</strong>, а почему пайп, а не файл?</p>]]></description>
			<author><![CDATA[null@example.com (Александр_)]]></author>
			<pubDate>Sat, 20 Oct 2012 09:33:18 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=64875#p64875</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Выполнение команды из переменной]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=64873#p64873</link>
			<description><![CDATA[<p>В переменной вы имеете текст. Текст состоит из той же последовательности символов, что и имя некой команды существующей в ahk.<br />Встроенных средств интерпретации текста в переменной как исполняемого кода в ahk нет.<br />Если в процессе написания скрипта у вас возникло желание выполнять текст как код — уместно пересмотреть используемый в написании подход. Если после вдумчивого поиска, альтернатив обсуждаемому решению не нашлось — существует <a href="http://www.autohotkey.net/~HotKeyIt/AutoHotkey/files/AutoHotkey-txt.html">AutoHotkey_H</a>. Подробности по ссылке.</p><p>В частных случаях можно обойтись:<br /></p><div class="codebox"><pre><code>
; ahk_l unicode
; способ подразумевает отсутствие взаимодействия запущенной команды и запускающего скрипта
var := &quot;msgbox&quot;
DynaRun(var)

DynaRun(tempScript, pipeName = &quot;&quot;)
{
    static DefaultArgs := [&quot;UInt&quot;, 2, &quot;UInt&quot;, 0, &quot;UInt&quot;, 255, &quot;UInt&quot;, 0, &quot;UInt&quot;, 0, &quot;Ptr&quot;, 0, &quot;Ptr&quot;, 0, &quot;Ptr&quot;]
    static BOM := Chr(0xFEFF)

    (pipeName = &quot;&quot; &amp;&amp; pipeName := &quot;AHK_&quot; . A_TickCount)

    pipeGA := DllCall(&quot;CreateNamedPipe&quot;, &quot;Str&quot;, &quot;\\.\pipe\&quot; pipeName, DefaultArgs*)
    pipe := DllCall(&quot;CreateNamedPipe&quot;, &quot;Str&quot;, &quot;\\.\pipe\&quot; pipeName, DefaultArgs*)
    if (pipe = -1 || pipeGA = -1)
        return false

    Run, % A_AhkPath . &quot; &quot;&quot;\\.\pipe\&quot; . pipeName . &quot;&quot;&quot;&quot;,, UseErrorLevel HIDE, processID
    if ErrorLevel
        MsgBox, 262144, ERROR, % &quot;Could not open file:`n &quot;&quot;\\.\pipe\&quot; . pipeName . &quot;&quot;&quot;&quot;

    DllCall(&quot;ConnectNamedPipe&quot;, &quot;Ptr&quot;, pipeGA, &quot;Ptr&quot;, 0), DllCall(&quot;CloseHandle&quot;, &quot;Ptr&quot;, pipeGA)
    DllCall(&quot;ConnectNamedPipe&quot;, &quot;Ptr&quot;, pipe, &quot;Ptr&quot;, 0)
    , tempScript := BOM . tempScript
    , tempScriptSize := (StrLen(tempScript)+1)*2
    if !DllCall(&quot;WriteFile&quot;, &quot;Ptr&quot;, pipe, &quot;Str&quot;, tempScript, &quot;UInt&quot;, tempScriptSize, &quot;UInt*&quot;, 0, &quot;Ptr&quot;, 0)
        return A_LastError
    DllCall(&quot;CloseHandle&quot;, &quot;Ptr&quot;, pipe)

    return processID
}</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (creature.ws)]]></author>
			<pubDate>Sat, 20 Oct 2012 00:33:03 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=64873#p64873</guid>
		</item>
		<item>
			<title><![CDATA[AHK: Выполнение команды из переменной]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=64872#p64872</link>
			<description><![CDATA[<p>Собственно сабж.В переменной бы имеем некую команду,нужно ее выполнить.</p>]]></description>
			<author><![CDATA[null@example.com (letopisec)]]></author>
			<pubDate>Fri, 19 Oct 2012 23:30:41 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=64872#p64872</guid>
		</item>
	</channel>
</rss>
