Communicating between Autohotkey and python

∥☆過路亽.° 提交于 2019-12-04 18:15:15

问题


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?


回答1:


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.




回答2:


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



来源:https://stackoverflow.com/questions/6135238/communicating-between-autohotkey-and-python

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!