<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; AHK: Выполнение переменного кода]]></title>
	<link rel="self" href="http://forum.script-coding.com/extern.php?action=feed&amp;tid=13300&amp;type=atom" />
	<updated>2019-04-14T17:29:58Z</updated>
	<generator>PunBB</generator>
	<id>http://forum.script-coding.com/viewtopic.php?id=13300</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Выполнение переменного кода]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=133605#p133605" />
			<content type="html"><![CDATA[<p>Нет.</p>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2019-04-14T17:29:58Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=133605#p133605</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Выполнение переменного кода]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=133603#p133603" />
			<content type="html"><![CDATA[<p><strong>Malcev</strong><br />Что нибудь ответили?</p>]]></content>
			<author>
				<name><![CDATA[serzh82saratov]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=27879</uri>
			</author>
			<updated>2019-04-14T14:01:03Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=133603#p133603</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Выполнение переменного кода]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=124986#p124986" />
			<content type="html"><![CDATA[<p>Написал, посмотрим, что ответит.</p>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2018-04-28T23:09:59Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=124986#p124986</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Выполнение переменного кода]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=124980#p124980" />
			<content type="html"><![CDATA[<p>Пиши lexikos&#039;у. <img src="//forum.script-coding.com/img/smilies/smile.png" width="15" height="15" /></p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2018-04-28T20:30:13Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=124980#p124980</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Выполнение переменного кода]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=124978#p124978" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>teadrinker пишет:</cite><blockquote><p>я просто хотел сказать, что данный код из хелпа не всегда годится.</p></blockquote></div><p>Наверное стоило бы на этот момент в хелпе заострить внимание (сделать пометку).</p>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2018-04-28T20:26:50Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=124978#p124978</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Выполнение переменного кода]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=124975#p124975" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>Malcev пишет:</cite><blockquote><p>Можно конвертировать</p></blockquote></div><p>В этом нет смысла, код, как правило, заранее неизвестен.<br /></p><div class="quotebox"><blockquote><p>Или через именованные каналы</p></blockquote></div><p>Так это понятно, я просто хотел сказать, что данный код из хелпа не всегда годится.</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2018-04-28T20:15:16Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=124975#p124975</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Выполнение переменного кода]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=124973#p124973" />
			<content type="html"><![CDATA[<p>Да, такие символы wscript похоже не понимает.<br />Можно конвертировать:<br /></p><div class="codebox"><pre><code>code := &quot;msgbox % Chr(10003)&quot;
ExecScript(code, false)

ExecScript(Script, Wait:=true)
{
    shell := ComObjCreate(&quot;WScript.Shell&quot;)
    exec := shell.Exec(&quot;AutoHotkey.exe /ErrorStdOut *&quot;)
    exec.StdIn.Write(script)
    exec.StdIn.Close()
    if Wait
        return exec.StdOut.ReadAll()
}</code></pre></div><p>Или через именованные каналы:<br /></p><div class="codebox"><pre><code>code := &quot;msgbox ✓&quot;
DynaRun(code)

DynaRun(TempScript, pipename=&quot;&quot;)
{
   static _:=&quot;uint&quot;,@:=&quot;Ptr&quot;
   If pipename =
      name := &quot;AHK&quot; A_TickCount
   Else
      name := pipename
   __PIPE_GA_ := DllCall(&quot;CreateNamedPipe&quot;,&quot;str&quot;,&quot;\\.\pipe\&quot; name,_,2,_,0,_,255,_,0,_,0,@,0,@,0)
   __PIPE_    := DllCall(&quot;CreateNamedPipe&quot;,&quot;str&quot;,&quot;\\.\pipe\&quot; name,_,2,_,0,_,255,_,0,_,0,@,0,@,0)
   if (__PIPE_=-1 or __PIPE_GA_=-1)
      Return 0
   Run, %A_AhkPath% &quot;\\.\pipe\%name%&quot;,,UseErrorLevel HIDE, PID
   If ErrorLevel
      MsgBox, 262144, ERROR,% &quot;Could not open file:`n&quot; __AHK_EXE_ &quot;&quot;&quot;\\.\pipe\&quot; name &quot;&quot;&quot;&quot;
   DllCall(&quot;ConnectNamedPipe&quot;,@,__PIPE_GA_,@,0)
   DllCall(&quot;CloseHandle&quot;,@,__PIPE_GA_)
   DllCall(&quot;ConnectNamedPipe&quot;,@,__PIPE_,@,0)
   script := (A_IsUnicode ? chr(0xfeff) : (chr(239) . chr(187) . chr(191))) TempScript
   if !DllCall(&quot;WriteFile&quot;,@,__PIPE_,&quot;str&quot;,script,_,(StrLen(script)+1)*(A_IsUnicode ? 2 : 1),_ &quot;*&quot;,0,@,0)
        Return A_LastError,DllCall(&quot;CloseHandle&quot;,@,__PIPE_)
   DllCall(&quot;CloseHandle&quot;,@,__PIPE_)
   Return PID
}</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2018-04-28T19:39:20Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=124973#p124973</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Выполнение переменного кода]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=124971#p124971" />
			<content type="html"><![CDATA[<p>Кстати, такой код не всегда годится:</p><div class="codebox"><pre><code>code := &quot;msgbox ✓&quot;
ExecScript(code, false)

ExecScript(Script, Wait:=true)
{
    shell := ComObjCreate(&quot;WScript.Shell&quot;)
    exec := shell.Exec(&quot;AutoHotkey.exe /ErrorStdOut *&quot;)
    exec.StdIn.Write(script)
    exec.StdIn.Close()
    if Wait
        return exec.StdOut.ReadAll()
}</code></pre></div>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2018-04-28T14:21:04Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=124971#p124971</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Выполнение переменного кода]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=124968#p124968" />
			<content type="html"><![CDATA[<p>В справке всё написано:<br /><a href="https://autohotkey.com/docs/commands/Run.htm">https://autohotkey.com/docs/commands/Run.htm</a><br /></p><div class="codebox"><pre><code>code := &quot;msgbox 1`nmsgbox 2&quot;
ExecScript(code, false)

ExecScript(Script, Wait:=true)
{
    shell := ComObjCreate(&quot;WScript.Shell&quot;)
    exec := shell.Exec(&quot;AutoHotkey.exe /ErrorStdOut *&quot;)
    exec.StdIn.Write(script)
    exec.StdIn.Close()
    if Wait
        return exec.StdOut.ReadAll()
}</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2018-04-28T09:16:32Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=124968#p124968</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Выполнение переменного кода]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=124966#p124966" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>Diman_Express пишет:</cite><blockquote><p>что если скачивать файл с сервера (текстовик), где будет код. Далее скрипт должен прочитать его и выполнить</p></blockquote></div><p>Подозреваю, на форуме есть примеры этой процедуры, но не знаю, как правильно искать. Есть действенный вариант такого метода чтения кода онлайн из Google Docs, например? Ткните, пожалуйста. Гугл выдал пару примеров некоторой давности - у меня не сработали.</p>]]></content>
			<author>
				<name><![CDATA[becauseim]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=33149</uri>
			</author>
			<updated>2018-04-28T02:17:57Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=124966#p124966</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Выполнение переменного кода]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=124948#p124948" />
			<content type="html"><![CDATA[<p>Тоже заинтересовался данной темой. Пришел к тому, что ahk все же должен быть установлен. Вот так, например, можно выполнить любой код в блокноте, не создавая никаких файлов:<br /></p><div class="codebox"><pre><code>F1::
		ControlGetFocus, ControlName, ahk_exe notepad.exe
		if (InStr(ControlName, &quot;Edit1&quot;))
		{
			ControlGetText, ScriptText, %ControlName%, ahk_exe notepad.exe
			RunTempScript(ScriptText, &quot;Unsaved Script - &quot; A_TickCount)
		}
return

RunTempScript(TempScript, name=&quot;&quot;)
{
	If name =
	pipe_name := A_TickCount
	Else
	pipe_name := name
	pipe_ga := CreateNamedPipe(pipe_name, 2)
	pipe    := CreateNamedPipe(pipe_name, 2)
	if (pipe=-1 or pipe_ga=-1)
	{
		MsgBox CreateNamedPipe failed.
		ExitApp
	}
	Run, %A_AhkPath% &quot;\\.\pipe\%pipe_name%&quot;,,,PID
	DllCall(&quot;ConnectNamedPipe&quot;,&quot;uint&quot;,pipe_ga,&quot;uint&quot;,0)
	DllCall(&quot;CloseHandle&quot;,&quot;uint&quot;,pipe_ga)
	DllCall(&quot;ConnectNamedPipe&quot;,&quot;uint&quot;,pipe,&quot;uint&quot;,0)
	Script := chr(0xfeff) TempScript
	if !DllCall(&quot;WriteFile&quot;,&quot;uint&quot;,pipe,&quot;str&quot;,Script,&quot;uint&quot;,(StrLen(Script)+1)*2,&quot;uint*&quot;,0,&quot;uint&quot;,0)
		MsgBox WriteFile failed: %ErrorLevel%/%A_LastError%
	DllCall(&quot;CloseHandle&quot;,&quot;uint&quot;,pipe)
	Return PID
}

CreateNamedPipe(Name, OpenMode=3, PipeMode=0, MaxInstances=255)
{
    return DllCall(&quot;CreateNamedPipe&quot;,&quot;str&quot;,&quot;\\.\pipe\&quot; Name,&quot;uint&quot;,OpenMode
        ,&quot;uint&quot;,PipeMode,&quot;uint&quot;,MaxInstances,&quot;uint&quot;,0,&quot;uint&quot;,0,&quot;uint&quot;,0,&quot;uint&quot;,0)
}</code></pre></div>]]></content>
			<author>
				<name><![CDATA[svoboden]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=34280</uri>
			</author>
			<updated>2018-04-27T07:49:21Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=124948#p124948</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Выполнение переменного кода]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=122366#p122366" />
			<content type="html"><![CDATA[<p><strong>ypppu</strong>, у меня тот же вопрос возник, когда я прочитал эту тему. Видимо зачарованное название темы, вдумайтесь только &quot;Выполнение переменного кода&quot;. Это как обсуждать переменный ток (если есть электрики), можно обсуждать бесконечно.</p>]]></content>
			<author>
				<name><![CDATA[Alectric]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=26027</uri>
			</author>
			<updated>2017-12-15T14:02:23Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=122366#p122366</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Выполнение переменного кода]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=122365#p122365" />
			<content type="html"><![CDATA[<p>Что происходит? <span class="postimg"><img src="http://i.smiles2k.net/icq_smiles/5.gif" alt="http://i.smiles2k.net/icq_smiles/5.gif" /></span></p>]]></content>
			<author>
				<name><![CDATA[ypppu]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=5974</uri>
			</author>
			<updated>2017-12-15T14:00:41Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=122365#p122365</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Выполнение переменного кода]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=122364#p122364" />
			<content type="html"><![CDATA[<p>Я не про последствия, я про рутину.</p>]]></content>
			<author>
				<name><![CDATA[Alectric]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=26027</uri>
			</author>
			<updated>2017-12-15T13:52:07Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=122364#p122364</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Выполнение переменного кода]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=122363#p122363" />
			<content type="html"><![CDATA[<p>Мне это ни о чем не говорит.<br />Но я только что запустил 1000 скомпилированных скриптов с кодом tooltip - никаких негативных последствий от </p><div class="quotebox"><blockquote><p>плодить ссылки на области памяти</p></blockquote></div><p> не обнаружил.</p>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2017-12-15T13:49:17Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=122363#p122363</id>
		</entry>
</feed>
