<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Серый форум &mdash; AHK: Как создать свою DLL и вызвать ее из AutoHotkey]]></title>
		<link>https://forum.script-coding.com/viewtopic.php?id=11536</link>
		<atom:link href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=11536&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[Недавние сообщения в теме «AHK: Как создать свою DLL и вызвать ее из AutoHotkey».]]></description>
		<lastBuildDate>Mon, 02 May 2016 21:26:25 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: AHK: Как создать свою DLL и вызвать ее из AutoHotkey]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=103289#p103289</link>
			<description><![CDATA[<p>Если нужно, вызвать функцию из DLL на C#, то можно переделать саму DLL и все будет работать. Я проверила, AutoHotkey вызывает функцию. <br />вот инструкция: <a href="http://jonxxx.me/13-metatrader/15-eksport-funktsij-iz-net-dll-c-dllexport-net-framework-v-metatrader">http://jonxxx.me/13-metatrader/15-ekspo … metatrader</a></p>]]></description>
			<author><![CDATA[null@example.com (Elena)]]></author>
			<pubDate>Mon, 02 May 2016 21:26:25 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=103289#p103289</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Как создать свою DLL и вызвать ее из AutoHotkey]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=103149#p103149</link>
			<description><![CDATA[<div class="quotebox"><cite>teadrinker пишет:</cite><blockquote><p>В первом примере у вас путаница с названиями: при компиляции testD<span style="color: red">D</span>L, при обращении — testD<span style="color: red">L</span>L.</p></blockquote></div><p>Это опечатка тут на форуме (уже исправила), я просто руками команды набирала и ошиблась, а так у меня все компилируется автоматически и имена фалов тоже автоматом вставляются.</p><div class="quotebox"><cite>Malcev пишет:</cite><blockquote><p>А битности dll и автохотки совпадают?</p></blockquote></div><p>Да это обязательно иначе не заработает.</p><p>Вот рабочее решение:<br />Файл <strong>testDLL.cpp</strong> будущей .dll:<br /></p><div class="codebox"><pre><code>
#include &lt;stdio.h&gt;

#define DLLEXPORT __declspec(dllexport)
#define DLLIMPORT __declspec(dllimport)

#ifdef __cplusplus
extern &quot;C&quot; {
#endif

    DLLEXPORT long int testfunc(long int a, long int b)
    {
        return a + b;
    }

#ifdef __cplusplus
}
#endif
</code></pre></div><p>Вот содержимое кода AutoHotkey:<br /></p><div class="codebox"><pre><code>
; --- тест вызова dll (кнопка поиск на мультимедиа клаве) ---
Browser_Search::
    Result := DllCall(&quot;testDLL.dll\testfunc&quot;, &quot;Int&quot;, 10, &quot;Int&quot;, 20 ,&quot;CDecl&quot;)
    MsgBox, DLL вернула значение: %Result% , ErrorLevel: %ErrorLevel%
return
</code></pre></div><p>Результат работы с C# библиотекой, на выходе имеем:<br /><strong>DLL вернула значение:&nbsp; 30, ErrorLevel: 0</strong></p><p>Слава богу, заработало! <img src="//forum.script-coding.com/img/smilies/smile.png" width="15" height="15" /></p>]]></description>
			<author><![CDATA[null@example.com (Elena)]]></author>
			<pubDate>Wed, 27 Apr 2016 20:34:39 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=103149#p103149</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Как создать свою DLL и вызвать ее из AutoHotkey]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=103147#p103147</link>
			<description><![CDATA[<p>А битности dll и автохотки совпадают?</p>]]></description>
			<author><![CDATA[null@example.com (Malcev)]]></author>
			<pubDate>Wed, 27 Apr 2016 20:10:46 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=103147#p103147</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Как создать свою DLL и вызвать ее из AutoHotkey]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=103145#p103145</link>
			<description><![CDATA[<p>В первом примере у вас путаница с названиями: при компиляции testD<span style="color: red">D</span>L, при обращении — testD<span style="color: red">L</span>L.</p>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Wed, 27 Apr 2016 19:52:34 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=103145#p103145</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Как создать свою DLL и вызвать ее из AutoHotkey]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=103143#p103143</link>
			<description><![CDATA[<p><strong>Malcev</strong>, приведенную инструкцию читала когда писала код, там все понятно. Там есть пример вызова функции из самого AutoHotkey, <strong>но</strong> нет примера как написать самому функцию в Dll библиотеке.<br />Коды ошибок приведены в тексте, я их пояснила.</p>]]></description>
			<author><![CDATA[null@example.com (Elena)]]></author>
			<pubDate>Wed, 27 Apr 2016 19:30:22 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=103143#p103143</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Как создать свою DLL и вызвать ее из AutoHotkey]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=103139#p103139</link>
			<description><![CDATA[<p><a href="https://autohotkey.com/docs/commands/DllCall.htm">https://autohotkey.com/docs/commands/DllCall.htm</a><br /></p><div class="quotebox"><blockquote><p>-3: The specified DllFile could not be accessed or loaded. If no explicit path was specified for DllFile, the file must exist in the system&#039;s PATH or A_WorkingDir. This error might also occur if the user lacks permission to access the file, or if AutoHotkey is 32-bit and the DLL is 64-bit or vice versa.</p><p>-4: The specified function could not be found inside the DLL.</p></blockquote></div>]]></description>
			<author><![CDATA[null@example.com (Malcev)]]></author>
			<pubDate>Wed, 27 Apr 2016 19:12:05 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=103139#p103139</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Как создать свою DLL и вызвать ее из AutoHotkey]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=103138#p103138</link>
			<description><![CDATA[<p><strong>serzh82saratov</strong> В первом случаи AutoHotkey вообще<strong> не</strong> видит Dll, во втором случаи он <strong>видит </strong>Dll но <strong>не </strong>может в ней найти функцию. Dll лежит в той же папке что и сам AutoHotkey, поэтому все должно работать без указания путей.<br />Есть подозрение что в исходные с++ и C# файлы нужно что-то добавить чтобы получились полноценные библиотеки. Что именно пока не знаю.</p>]]></description>
			<author><![CDATA[null@example.com (Elena)]]></author>
			<pubDate>Wed, 27 Apr 2016 19:12:02 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=103138#p103138</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Как создать свою DLL и вызвать ее из AutoHotkey]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=103137#p103137</link>
			<description><![CDATA[<p>Может быть LoadLibrary сначала, или путь к длл указывать полные.</p>]]></description>
			<author><![CDATA[null@example.com (serzh82saratov)]]></author>
			<pubDate>Wed, 27 Apr 2016 19:05:06 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=103137#p103137</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Как создать свою DLL и вызвать ее из AutoHotkey]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=103135#p103135</link>
			<description><![CDATA[<p>Вот вариант кода для C# библиотеки:<br /></p><div class="codebox"><pre><code>
using System;
public class ClassFunc
{
    public int testfunc(int a, int b)
    {
        return a + b;
    }
}
</code></pre></div><p>Команда для компиляции этого файла:<br /><strong>csc.exe /t:library /out:testDLL.dll testDLL.cs</strong></p><p>AutoHotkey видит библиотеку но не может найти в ней функцию<br />Результат работы с C# библиотекой, на выходе имеем:<br /><strong>DLL вернула значение:&nbsp; , ErrorLevel: -4</strong></p><p>ErrorLevel: -4: это значит указанная функция не найдена в DLL.</p><p>Пробовала варианты, ни один из вариантов не работает:<br /></p><div class="codebox"><pre><code>
Result := DllCall(&quot;testDLL.dll\testfunc&quot;, &quot;Int&quot;, 10, &quot;Int&quot;, 20)
Result := DllCall(&quot;testDLL.dll\ClassFunc.testfunc&quot;, &quot;Int&quot;, 10, &quot;Int&quot;, 20)
Result := DllCall(&quot;testDLL.dll\ClassFunc\testfunc&quot;, &quot;Int&quot;, 10, &quot;Int&quot;, 20)
</code></pre></div><p>Что нужно поменять чтобы AutoHotkey смог вызвать функцию из C# библиотеки?</p>]]></description>
			<author><![CDATA[null@example.com (Elena)]]></author>
			<pubDate>Wed, 27 Apr 2016 18:53:23 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=103135#p103135</guid>
		</item>
		<item>
			<title><![CDATA[AHK: Как создать свою DLL и вызвать ее из AutoHotkey]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=103126#p103126</link>
			<description><![CDATA[<p>Не получается вызвать свою функцию (функция в своей .dll) из AutoHotkey <img src="//forum.script-coding.com/img/smilies/sad.png" width="15" height="15" />.</p><p>Вот файл <strong>testDLL.cpp</strong> будущей .dll:<br /></p><div class="codebox"><pre><code>
#include &lt;stdio.h&gt;

long int testfunc(long int a, long int b)
{
   return a + b;
}
</code></pre></div><p>Компилирую его, в независимую dll библиотеку используя MinGW, следующими командами:<br /><strong>g++.exe -o testDLL.o -c testDLL.cpp<br />g++.exe -static -static-libgcc -static-libstdc++ -shared -o testDLL.dll testDLL.o</strong></p><br /><p>Вот содержимое кода AutoHotkey:<br /></p><div class="codebox"><pre><code>
; --- тест вызова dll (кнопка поиск на мультимедиа клаве) ---
Browser_Search::
    Result := DllCall(&quot;testDLL.dll\testfunc&quot;, &quot;Int&quot;, 10, &quot;Int&quot;, 20)
    MsgBox, DLL вернула значение: %Result% , ErrorLevel: %ErrorLevel%
return
</code></pre></div><p>В результате всего этого на выходе имеем:<br /><strong>DLL вернула значение:&nbsp; , ErrorLevel: -3</strong></p><p>ErrorLevel: -3: это значит невозможно обратиться к указанному DllFile.</p><p>Пробовала убрать из .cpp файла аргументы функции <strong>testfunc </strong>и просто сделать <strong>return 1;</strong> и соответственно вызывать DLL без параметров - это тоже не помогает. Dll лежит в той же директории что и сам AutoHotkey.</p><p>Кто уже писал свои .dll? Подскажите что я делаю не так и что нужно чтобы вызвать функцию из своей .dll?<br />Всем спасибо кто откликнется <img src="//forum.script-coding.com/img/smilies/smile.png" width="15" height="15" />.</p>]]></description>
			<author><![CDATA[null@example.com (Elena)]]></author>
			<pubDate>Wed, 27 Apr 2016 17:03:58 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=103126#p103126</guid>
		</item>
	</channel>
</rss>
