<?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="https://forum.script-coding.com/extern.php?action=feed&amp;tid=18248&amp;type=atom" />
	<updated>2024-07-15T13:19:43Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=18248</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Исполнение кода из стороннего файла]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=161258#p161258" />
			<content type="html"><![CDATA[<p>Этот цикл<br /></p><div class="codebox"><pre><code>While DllCall(dllpath . &quot;\ahkReady&quot;) {
    Sleep 100
}</code></pre></div><p>нужен только для того, чтобы основной скрипт не завершился раньше, чем тот, который запускается через dll. Вместо этого можно просто добавить в начало #Persistent:<br /></p><div class="codebox"><pre><code>#Persistent
script =
(
    #NoTrayIcon
    counter := 0
    Loop 30 {
        ToolTip `% ++counter
        Sleep 100
    }
)

; битность dll должна соответствовать битности скрипта, в котором она загружается
dllPath := A_ScriptDir . &quot;\AutoHotkey.dll&quot;
if !DllCall(&quot;LoadLibrary&quot;, &quot;Str&quot;, dllpath) {
    MsgBox Не удалось загрузить AutoHotkey.dll
}
DllCall(dllpath . &quot;\ahktextdll&quot;, &quot;Str&quot;, script, &quot;Str&quot;, &quot;&quot;, &quot;CDecl&quot;)</code></pre></div>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2024-07-15T13:19:43Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=161258#p161258</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Исполнение кода из стороннего файла]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=161257#p161257" />
			<content type="html"><![CDATA[<p>Я уже не пишу на AHK v1, лень разбираться.<br />Должно быть так:<br /></p><div class="codebox"><pre><code>script =
(
    #NoTrayIcon
    counter := 0
    Loop 30 {
        ToolTip `% ++counter
        Sleep 100
    }
)

; битность dll должна соответствовать битности скрипта, в котором она загружается
dllPath := A_ScriptDir . &quot;\AutoHotkey.dll&quot;
if !DllCall(&quot;LoadLibrary&quot;, &quot;Str&quot;, dllpath) {
    MsgBox Не удалось загрузить AutoHotkey.dll
}
DllCall(dllpath . &quot;\ahktextdll&quot;, &quot;Str&quot;, script, &quot;Str&quot;, &quot;&quot;, &quot;CDecl&quot;)
While DllCall(dllpath . &quot;\ahkReady&quot;) {
    Sleep 100
}</code></pre></div>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2024-07-15T13:15:16Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=161257#p161257</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Исполнение кода из стороннего файла]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=161255#p161255" />
			<content type="html"><![CDATA[<p><strong>teadrinker</strong></p><p>! Проблему решил, нужно было просто вынести LoadLibrary за цикл !</p><br /><br /><p>При запуске этого кода на AHK_H выдает ошибки (Exit code: 3221226525, Exit code: 3221225477, Exit code: 3221226356):</p><div class="codebox"><pre><code>
#SingleInstance Force

Loop {
	FileRead, Read, test.txt
	if RegExMatch(Read, &quot;123&quot;) {
		dllpath := A_WorkingDir . &quot;\AutoHotkey.dll&quot;
		DllCall(&quot;LoadLibrary&quot;, &quot;Str&quot;, dllpath)
		Code =
		(
		#SingleInstance, Force
		
		Function_Run() {
			SoundBeep, 500
		}

		Function_Run()
		While DllCall(dllpath &quot;\ahkReady&quot;) {
			Sleep, 100
		}
		)
		dll := DllCall(dllpath &quot;\ahktextdll&quot;,&quot;Str&quot;,Code,&quot;Str&quot;,&quot;&quot;,&quot;Str&quot;,&quot;&quot;,&quot;CDecl&quot;)
		VarSetCapacity(dll, 0)
		FileDelete, test.txt
		continue
	}
}

-::
FileAppend, 123, test.txt
return
</code></pre></div><p>Не знаете, в чем может быть дело? (ошибка появляется после 2-5 запуска нового потока)</p>]]></content>
			<author>
				<name><![CDATA[Ladanu_ML]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=43880</uri>
			</author>
			<updated>2024-07-15T12:09:11Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=161255#p161255</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Исполнение кода из стороннего файла]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=161254#p161254" />
			<content type="html"><![CDATA[<p>Спасибо, щас попробую)</p>]]></content>
			<author>
				<name><![CDATA[Ladanu_ML]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=43880</uri>
			</author>
			<updated>2024-07-14T13:10:51Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=161254#p161254</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Исполнение кода из стороннего файла]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=161253#p161253" />
			<content type="html"><![CDATA[<p>Да, возможно через AutoHotkey.dll, гуглите.</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2024-07-14T12:35:26Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=161253#p161253</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[AHK: Исполнение кода из стороннего файла]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=161252#p161252" />
			<content type="html"><![CDATA[<p>Добрый день.<br />Возможно ли в AHK исполнение кода из стороннего файла? (Имеется ввиду чтение некоторого кода из файла и исполнение его в рабочем (если возможно, то в скомпилированном) скрипте).</p>]]></content>
			<author>
				<name><![CDATA[Ladanu_ML]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=43880</uri>
			</author>
			<updated>2024-07-14T12:06:54Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=161252#p161252</id>
		</entry>
</feed>
