Page 1 of 1

Custom COM Objects & DLL Library compilation?

Posted: 17 Aug 2016, 18:08
by sancarn
I'm not sure if either of these things are possible or within the scope of what the developers want AHK to be but:

------------------------------------------------------------------------------

1. Custom COM Objects

Currently we can create COM objects of Excel, Word etc., which are examples of where COM is used to automate applications. However COM is also used to help programming in general (e.g. Scripting.Dictionary). My first wish would be to give AHK developers the means to create these custom scripting libraries for ourselves (i.e. Allow developers to create COM libraries, which can be used from other programming languages e.g. VBA).

2. Compile to DLL Function Libraries

On a similar topic as above, a lot of the time I work in languages that don't actually support objects, however they do support DLL calls. Example in MapBasic:

Code: Select all

Declare Method RegionalLongDate Class "MBExtensions.MBDateAndTime" Lib "MBExtensions.dll" (ByVal sDateString as string) as string
It would be nice if we could compile AHK to DLLs where we could use class methods in a similar fashion. Currently I believe we can create DLLs as resource files but we cannot call functions from those DLLs.

------------------------------------------------------------------------------

Re: Custom COM Objects & DLL Library compilation?

Posted: 18 Aug 2016, 17:51
by lexikos
Your requests are outside the scope of what I want AutoHotkey to be. However, AutoHotkey is open source, so anyone with the right skills and/or dedication can implement those things if desired.

No. 1 is probably already possible by creating an out-of-process COM server with DllCall. I'm not sure whether it's been done, though. Scripts can register objects with ObjRegisterActive to be retrieved by other processes calling GetActiveObject or equivalent.

Re: Custom COM Objects & DLL Library compilation?

Posted: 20 Aug 2016, 09:44
by HotKeyIt
You can compile AutoHotkey.dll and use it in another program (inluded compiler must be used!).
You will need to LoadLibrary, then call the function ahkdll to start script and then use other exported function, see http://hotkeyit.github.io/v2/docs/AutoHotkeyDll.htm.
AutoHotkey.dll supports COM too, also when compiled, see http://hotkeyit.github.io/v2/docs/COMInterface.htm.

Simple example for compiled AutoHotkey.dll

Code: Select all

#Persistent
fun(a,b){
  return a+b
}
Call the dll (v1):

Code: Select all

ahk:=ComObjCreate("AutoHotkey.Script")
ahk.ahkdll()
MsgBox % ahk.ahkFunction("fun",2,3)
ahk.ahkterminate(), ahk:="" ; exit

Re: Custom COM Objects & DLL Library compilation?

Posted: 07 Sep 2016, 07:43
by -_+
HotKeyIt, multiple recent MS decisions/actions push a lot of users away from Windows, some of them migrate (or want to migrate) to Linux-based OSes.
We already know lexikos' stance on the question, but we don't know yours.
Could you port your AHK_Hv2 to linux?

Re: Custom COM Objects & DLL Library compilation?

Posted: 10 Sep 2016, 04:28
by HotKeyIt
There are no plans to port AHK_H to linux.

Re: Custom COM Objects & DLL Library compilation?

Posted: 11 Sep 2016, 06:15
by -_+
Okay, thank you.