AutoHotkey Community

It is currently May 26th, 2012, 7:40 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 563 posts ]  Go to page Previous  1, 2, 3, 4, 5 ... 38  Next
Author Message
PostPosted: April 23rd, 2009, 7:13 am 
Offline

Joined: August 3rd, 2007, 8:01 am
Posts: 555
Location: Houston, TX
** 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 May 23rd, 2009, 3:21 am, edited 2 times in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject: ahkldl v6
PostPosted: April 28th, 2009, 6:38 am 
Offline

Joined: August 3rd, 2007, 8:01 am
Posts: 555
Location: Houston, TX
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 May 23rd, 2009, 3:16 am, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject: Autohotkey.dll
PostPosted: May 8th, 2009, 5:39 am 
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


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: May 8th, 2009, 9:14 am 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7502
Location: Australia
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 8th, 2009, 6:46 pm 
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. :lol: 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.


Report this post
Top
  
Reply with quote  
PostPosted: May 8th, 2009, 7:29 pm 
Offline

Joined: August 3rd, 2007, 8:01 am
Posts: 555
Location: Houston, TX
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 May 9th, 2009, 5:58 am, edited 3 times in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 9th, 2009, 3:15 am 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7502
Location: Australia
_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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 9th, 2009, 5:55 am 
Offline

Joined: August 3rd, 2007, 8:01 am
Posts: 555
Location: Houston, TX
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject: python example
PostPosted: May 9th, 2009, 6:23 am 
Offline

Joined: August 3rd, 2007, 8:01 am
Posts: 555
Location: Houston, TX
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 9th, 2009, 7:24 am 
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 :lol: Sorry for off-top, thank you for your replies.


Report this post
Top
  
Reply with quote  
PostPosted: May 10th, 2009, 3:01 pm 
Offline

Joined: May 10th, 2009, 2:53 pm
Posts: 3
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!


Report this post
Top
 Profile  
Reply with quote  
PostPosted: May 11th, 2009, 7:13 am 
Offline

Joined: May 10th, 2009, 2:53 pm
Posts: 3
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?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 15th, 2009, 7:49 am 
Offline

Joined: July 3rd, 2004, 1:03 pm
Posts: 121
OMG. Have not been around in a while, come back and this. Good damn job.


Report this post
Top
 Profile  
Reply with quote  
PostPosted: May 15th, 2009, 1:40 pm 
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


Report this post
Top
  
Reply with quote  
 Post subject: ahkEmacs
PostPosted: May 16th, 2009, 2:46 am 
Offline

Joined: August 3rd, 2007, 8:01 am
Posts: 555
Location: Houston, TX
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 May 17th, 2009, 9:19 pm, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 563 posts ]  Go to page Previous  1, 2, 3, 4, 5 ... 38  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: Alpha Bravo and 2 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group