AutoHotkey Community

It is currently May 27th, 2012, 12:55 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 18 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: python?
PostPosted: September 5th, 2004, 3:08 pm 
Offline

Joined: September 4th, 2004, 8:44 pm
Posts: 74
Location: UK
i saw a note somewhere about integration with VBS.

i don't suppose there are any python users out there? gui4cli has an interface to python and the source code is available:

http://users.hol.gr/~dck/g4c/dll/python.htm

i have no idea whether it is desirable or easy to link up to python, but i for one would appreciate it.

cheers

jack


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 5th, 2004, 3:30 pm 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
I checked it out and it looks like it might be a good feature (since Python appears to have an easy interface mechanism). However, if you would want the two languages to share variables and such, I imagine that's more difficult.

From reading the docs more, it looks like the interface is FROM Python to Gui4Cli, not so much the other way around. In light of this, perhaps AutoHotkey can be made to have a more generic interface so that external languages such as Python can send messages to a running ahk script to pass data to it or tell it to run a subroutine.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 5th, 2004, 3:57 pm 
Offline

Joined: September 4th, 2004, 8:44 pm
Posts: 74
Location: UK
Quote:
From reading the docs more, it looks like the interface is FROM Python to Gui4Cli, not so much the other way around


dunno, but since there is a python dll, i suppose that could be the case. i'm not a programmer...

there are python functions to run gui4cli commands and to put and get gui4cli variables. i assume that that is not what you mean when you say 'share variables'?

jack


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 5th, 2004, 4:56 pm 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
Quote:
there are python functions to run gui4cli commands and to put and get gui4cli variables. i assume that that is not what you mean when you say 'share variables'?
That's interesting. I think what might ultimately wind up being best is giving AutoHotkey an interface so that any external languages can do the following with a running ahk script:
1) Pass data into it.
2) Get data out of it.
3) Tell it to execute a subroutine.

Some of the above might be possible with Post/SendMessage (assuming the other language had those functions). There are also other ways to send data using interprocess comms.

However, what someone with expertise in Python (or any other external language) would have to finish the other side of the bridge by actually writing it in that external language.

But you might have had in mind something more like the following hypothetical example:
#PythonStart
... have actual Python-script inline here ...
#PythonEnd

In any case, I'll add these details to the to-do list for further investigation in the future. Thanks for pointing out the possibilities.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 5th, 2004, 5:26 pm 
Offline

Joined: September 4th, 2004, 8:44 pm
Posts: 74
Location: UK
Quote:
But you might have had in mind something more like the following hypothetical example:
#PythonStart
... have actual Python-script inline here ...
#PythonEnd


well, partially. that would indeed be useful...but the gui4cli mechanism means that python sits around... i wrote a gui4cli program that builds a sql search string based on the user's selection.

gui4cli then tells the waiting python to execute the search on a remote database. python writes a summary of the results (to a file) and control passes back to gui4cli.

gy4cli loads the results summary and then the user can click any one to see the full details. the details come from python, which writes a temporary file and then launches that file in the user's editor.

it sounds messy, but it works nicely.

i think the best way to determine how the gui4cli implementation works may be to ask dimitri (the gui4cli chap) himself. (i would ask him, but i don't know how to phrase the question and wouldn't be able to understand the answer!)

jack


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 5th, 2004, 6:28 pm 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
Good info, thanks. By the way, in case you didn't see the post, there's an alpha-test version of AutoHotkey's built-in GUI features here: http://www.autohotkey.com/forum/viewtopic.php?t=748


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 5th, 2004, 6:35 pm 
Offline

Joined: September 4th, 2004, 8:44 pm
Posts: 74
Location: UK
Quote:
By the way, in case you didn't see the post, there's an alpha-test version of AutoHotkey's built-in GUI features


yes, tried that yesterday. it worked beautifully and i hacked around with it a little. i didn't manage to break it, but would really like to see the docs, which i'm sure would make things a little clearer.

i tend to use radio buttons quite a bit, but i see you may be putting them off until later.


jack


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 5th, 2004, 7:12 pm 
Quote:
#PythonStart
... have actual Python-script inline here ...
#PythonEnd


I guess I've seen something similar - somewhere :wink:

Quote:
VBStart
reads from VBSTART to VBEND and stores the VBScript code between the two markers for later execution by the VBRun, or VBEval commands
VBEnd

VBRun
VBEval


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: September 5th, 2004, 7:34 pm 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
Yes, that's true. Hopefully I'll find time to research these integration features someday soon, unless someone else gets to it first.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 6th, 2004, 7:54 pm 
Actually, from what I've seen of lua integration, it might be the best for the sort of thing we're talking about here. I've seen some tutorials for doing this in C, and I've actually embedded a lua engine in a c# program, and it's really really easy to pass data in, set up functions, and execute those functions. It's also really easy to register new functions (like AHK's functions). Sorry, I have no links off the top of my head, I can post some when I get back from work.

Quick for-instance (sorry this is for c# but I believe the concept is pretty much the same in C)
Code:
LuaInterface.Lua interp = new LuaInterface.Lua();
Module m = n Module(); //this class would contain the methods you want to access in the script
Lua("mod") = m;
Lua.RunString("m.method();");
//and you can get data in and out like so
//say you have a variable called this
int i = Lua.GetNumber("this");


More later if you need it.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: September 6th, 2004, 11:01 pm 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
Sounds interesting; any additional links would be welcome.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 7th, 2004, 6:14 pm 
Here's the tutorial I couldn't find before: http://www.gamedev.net/reference/programming/features/lua/

And the lua documentation, source code, and the book Programming In Lua are available at http://www.lua.org

Lua's kinda designed for this sort of thing so...


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: September 7th, 2004, 6:15 pm 
Offline

Joined: July 2nd, 2004, 11:53 pm
Posts: 207
Oops, forgot to log in, I'm in class. :oops:

That was me.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 7th, 2004, 10:06 pm 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
Thanks for the links. I've made a note to check them out when the time comes to research integration features.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 19th, 2005, 10:34 pm 
Offline

Joined: May 12th, 2005, 4:37 pm
Posts: 2
Hi, I have been wishing for a python integration a few times while using AHK now. I mean the ability to call python from AHK. My reasons are

1) I have limited wetware memory resources for new programming languages, therefore using AHK as yet another scripting language in my life is somewhat inefficient for me. To put it shortly: IMHO python is a standard language, whereas AHK is a special purpose language.

2) Much more important: I would like to draw from the wealth of library functions of python (it comes with batteries included, as they say). Text processing (including structured text like XML), operating system interface, you name it, it's there. AHK is really powerful, but python has more to offer in many areas.

So are there still any plans for this kind of integration? I would love it.

Alternative approach idea (just thinking out loud): Create a library providing all the AHK keyboard handing functions (including hotstrings, creating the necessary hooks and event loop) to python. I have no idea whether this is feasible.

- Achim


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 18 posts ]  Go to page 1, 2  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 3 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