 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
tinku99
Joined: 03 Aug 2007 Posts: 513 Location: Houston, TX
|
Posted: Thu Apr 23, 2009 6:13 am Post subject: revision 5: dynamically load #inludes |
|
|
** Revision 5 (04/22/2009)
dynamically load #include scripts
addFile(str file, uchar aAllowDuplicateInclude, uchar aIgnoreLoadFailure)
use this to load new functions or labels.
dynamic #Directives will probably not work.
Examples
Last edited by tinku99 on Sat May 23, 2009 2:21 am; edited 2 times in total |
|
| Back to top |
|
 |
tinku99
Joined: 03 Aug 2007 Posts: 513 Location: Houston, TX
|
Posted: Tue Apr 28, 2009 5:38 am Post subject: ahkldl v6 |
|
|
added experimental threading support using multiple copies of the dll
see examples here
It turns out, I can just load the dll multiple times under different names.
giving thread local scripts. Shared thread variables should be easy with Lexikos' __alias(alias, alias_for) function in LowLevel..
Its probably best to keep separate copies of functions in scripts especially if you want to run time consuming functions at the same time: as in this example, however, sharing of functions is possible, if you avoid entangled variables (gui variables and builtin's such as A_Index and A_ScriptName), and don't run them at the same time.
V6. Merged with AutoHotkey v.1.0.48.02_L27
V1: AutoHotkey.dll compatible with v1.0.47.06, merged with ahkdll-0.6
Last edited by tinku99 on Sat May 23, 2009 2:16 am; edited 1 time in total |
|
| Back to top |
|
 |
_Slav2 Guest
|
Posted: Fri May 08, 2009 4:39 am Post subject: Autohotkey.dll |
|
|
Could you please explain for noob. Autohotkey.dll is not like IrohAhk and still requires ahk-script in the text form? Could you please write example for something absolutely common like what to do if I want to execute two command script from C# using autohotkey.dll, is this possible?
Pixelgetcolor, color1, 100, 100
Sleep, 1000 |
|
| Back to top |
|
 |
Lexikos
Joined: 17 Oct 2006 Posts: 7299 Location: Australia
|
Posted: Fri May 08, 2009 8:14 am Post subject: |
|
|
| If you are using C# or another .NET language, you are probably better off with IronAhk. This AutoHotkey.dll allows other programs to host AutoHotkey scripts, but does not (yet?) expose commands/functions directly to other languages. |
|
| Back to top |
|
 |
_Slav2 Guest
|
Posted: Fri May 08, 2009 5:46 pm Post subject: |
|
|
I am looking for a way how to faster convert existing autohotkey script to C# program, because it is not a problem to decompile any autohotkey script with proper decompiler. If I will have to parse 10000 line code to 10000 variables and send them as a parameters to autohotkey.dll then this is ok. Another question if we can use autohotkey.dll for this task, because of the license to be open source. If yes, then I need a little help on how to use this dll file. This is temporary solution of cause, finally we should work with IronAhk functions. Thabk you for your reply. |
|
| Back to top |
|
 |
tinku99
Joined: 03 Aug 2007 Posts: 513 Location: Houston, TX
|
Posted: Fri May 08, 2009 6:29 pm Post subject: AutoHotkey.dll with csharp |
|
|
You can host the dll in a csharp application using techniques described here and at codeproject. The second link includes a code example.
If you just modify the relevant lines with:
| Code: |
[DllImport("Invoke", CharSet=CharSet.Ansi)]
public extern static int InvokeFunc(int funcptr, string script, string message, string title);
static void Main(string[] args) {
int hmod=LoadLibrary("AutoHotkey.dll");
int funcaddr=GetProcAddress(hmod, "ahkdll");
int result=InvokeFunc(funcaddr, "dllclient.ahk", "", "");
...}
|
modified csharp example: here
You will also need the Invoke function code from the codeproject link.
I agree with Lexikos, that if you are using dotnet, you should probably invest more time in learning IronAhk.
I may expose more AutoHotkey built in functions, but there are a few other things that are higher on my todo list.
AutoHotkey.dll, is GPL v2.
Edit3:
Thanks to Lexikos for pointing out that the CharSet can be specified as ansi.
Last edited by tinku99 on Sat May 09, 2009 4:58 am; edited 3 times in total |
|
| Back to top |
|
 |
Lexikos
Joined: 17 Oct 2006 Posts: 7299 Location: Australia
|
Posted: Sat May 09, 2009 2:15 am Post subject: |
|
|
| _Slav2 wrote: | | I am looking for a way how to faster convert existing autohotkey script to C# program, because it is not a problem to decompile any autohotkey script with proper decompiler. | Funny. C# decompilers aren't that much worse, or any more difficult.
| Quote: | | Another question if we can use autohotkey.dll for this task, because of the license to be open source. | The GPL probably will not allow it.
| tinku99 wrote: | You can host the dll in a csharp application using techniques described here and at codeproject. ... The only issue is that ahkdll() expects a char* for the parameters (scriptname),
| It would be much more typical to use DllImport if the function doesn't need to be invoked dynamically. With DllImport you can specify that string parameters are marshalled in the Ansi character set. |
|
| Back to top |
|
 |
tinku99
Joined: 03 Aug 2007 Posts: 513 Location: Houston, TX
|
Posted: Sat May 09, 2009 4:55 am Post subject: |
|
|
| Lexikos wrote: | | _Slav2 wrote: |
Another question if we can use autohotkey.dll for this task, because of the license to be open source. | The GPL probably will not allow it.
With DllImport you can specify that string parameters are marshalled in the Ansi character set. |
Linking against a GPL dll, including late binding, appears to bless the hosting application with GPL as well.
The codeproject example actually does use DllImport... It also allows dynamic function calls through the Invoke function written in asm which facilitates function pointers. Thanks for pointing out the solution to the unicode to ansi translation problem. |
|
| Back to top |
|
 |
tinku99
Joined: 03 Aug 2007 Posts: 513 Location: Houston, TX
|
Posted: Sat May 09, 2009 5:23 am Post subject: python example |
|
|
callbacks into python are fairly straightforward with ctypes.
Python 3.x example:
python host
ahk client
startup the python interpreter, and run the following
| Code: |
from ctypes import *
ahk = cdll.AutoHotkey
CMPFUNC = CFUNCTYPE(c_int, c_int)
def py_cmp_func(a):
print("py_cmp_func", a)
return a
cmp_func = CMPFUNC(py_cmp_func)
fx = create_string_buffer(str(cast(cmp_func, c_void_p).value))
pyclient = create_string_buffer("pyclient.ahk") # no unicode in ahk
ahk.ahkdll(pyclient, "", fx)
|
I don't know why the calling python functions from c example is so convoluted in the python documentation, requiring compilation of python and using the python.h header. I can see it if you're embedding python, but for extending it:
It was much easier to adapt the ctypes example here |
|
| Back to top |
|
 |
_Slav2 Guest
|
Posted: Sat May 09, 2009 6:24 am Post subject: |
|
|
| Lexikos wrote: | | Funny. C# decompilers aren't that much worse, or any more difficult. | I am going to use Intellilock. http://www.eziriz.com/intellilock.htm to protect C# compilation. What options exist for autohotkey code? I could find nothing but found decompiler which decompile everything instead Sorry for off-top, thank you for your replies. |
|
| Back to top |
|
 |
harry.liang
Joined: 10 May 2009 Posts: 3
|
Posted: Sun May 10, 2009 2:01 pm Post subject: I am looking forward calling ahk directly in python! |
|
|
| Lexikos wrote: | | If you are using C# or another .NET language, you are probably better off with IronAhk. This AutoHotkey.dll allows other programs to host AutoHotkey scripts, but does not (yet?) expose commands/functions directly to other languages. |
I love python and I love autohotkey, I am looking forward calling ahk commands/functions directly in python! |
|
| Back to top |
|
 |
harry.liang
Joined: 10 May 2009 Posts: 3
|
Posted: Mon May 11, 2009 6:13 am Post subject: Re: I am looking forward calling ahk directly in python! |
|
|
| harry.liang wrote: | | Lexikos wrote: | | If you are using C# or another .NET language, you are probably better off with IronAhk. This AutoHotkey.dll allows other programs to host AutoHotkey scripts, but does not (yet?) expose commands/functions directly to other languages. |
I love python and I love autohotkey, I am looking forward calling ahk commands/functions directly in python! |
Nobody care about this feature? |
|
| Back to top |
|
 |
AHKnow
Joined: 03 Jul 2004 Posts: 121
|
Posted: Fri May 15, 2009 6:49 am Post subject: |
|
|
| OMG. Have not been around in a while, come back and this. Good damn job. |
|
| Back to top |
|
 |
EverReef Guest
|
Posted: Fri May 15, 2009 12:40 pm Post subject: Re: I am looking forward calling ahk directly in python! |
|
|
| harry.liang wrote: |
I love python and I love autohotkey, I am looking forward calling ahk commands/functions directly in python! |
same here with php |
|
| Back to top |
|
 |
tinku99
Joined: 03 Aug 2007 Posts: 513 Location: Houston, TX
|
Posted: Sat May 16, 2009 1:46 am Post subject: ahkEmacs |
|
|
| AHKnow wrote: | | OMG. Have not been around in a while, come back and this. Good damn job. |
Thanks AHKnow.
Here is a AutoHotkey.dll in Emacs:patch and binaries.
Get a regular distribution of emacs, and just replace the bin folder with the ahkEmacs binaries.
Features added to emacs:
Access to pointers. (strings for now, will add pointers to other LispObjects )
Callback to eval.
SendMessage.
Instructions for demo.
do meta-x ielm in emacs followed by...
| Code: | (loadmodule "dllclient.ahk" "" "parameter")
(setq message "hello from emacs")
(sendmsg message)
(pointer message)
;; from ahk side, press F3, to eval an expression in emacs
;; press F1 from ahk side to use emacs pointer for access to emacs string
|
Last edited by tinku99 on Sun May 17, 2009 8:19 pm; edited 1 time in total |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|