Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Communicating between Autohotkey and python

Is there a way to send some parameter from autohotkey to python.

Using Autohot key I read some number from the notepad and store in a variable and now I want to send this number to the python code in order to do some calculations.

My Autohotkey code is:

controlGetText, telphoneNumber, Edit1, Untitled - Notepad

And I want to send this telphoneNumber to python file.

Is there a way I can do that?

Do I need to create an exe file of a python and then call from autohotkey? For example:

RunWait,  C:\Button\button.exe telphoneNumber

Or do I need to run command prompt commands from autohotkey to run python program? Something like:

Run Cmd Python  C:\Button\button.py telphoneNumber

I do not know which is the best way as I am newbie in Autohotkey.

Any suggestion will be appreciated.

EDIT:

However I succeded in sending parameter by using run command from autohotkey, which will execute the python file from command prompt.

Run Cmd \k "Python  C:\Button\button.py %telphoneNumber%"

But still want to know if this is the right solution, or if there are others?

like image 480
Rohita Khatiwada Avatar asked May 26 '11 07:05

Rohita Khatiwada


2 Answers

Inter-process communication would be capable of sending the information while the Python script is already running.

Forum thread: http://www.autohotkey.com/forum/topic21699.html (there's a nice documentation link in that post)

You could also use TCP/IP Network communication (like in the post below), but that probably wouldn't be quite as slick as using IPC.

Forum thread: http://www.autohotkey.com/forum/topic13829.html

like image 153
camerb Avatar answered Nov 01 '22 01:11

camerb


The way you got it working is the easiest, and probably best, method of accomplishing what you want.

Communication between applications can be done with more methods then you probably can imagine, but as long as it doesn't have to be realtime you can call your programs with arguments, as it is easy and reliable.

like image 31
gnur Avatar answered Nov 01 '22 01:11

gnur