[ahk]将Python和AutoHotkey结合起来
2010-04-15 15:02
1131 查看
http://www.autohotkey.com/forum/topic53773.html
Q:I am searching for is a way to execute AHK commands from a Python script. Is this possible?
A:Yes. Here is an example.
tested with python2.6, requires AutoHotkey.dll in the working directory or path...
ahkpython.ahk:
ahkpython.py
remarks:
create_string_buffer is required because autohotkey.dll exported functions do not work with unicode.
See HotkeyIt's excellent chm help file for documentation on the functions.
Q:I am searching for is a way to execute AHK commands from a Python script. Is this possible?
A:Yes. Here is an example.
tested with python2.6, requires AutoHotkey.dll in the working directory or path...
ahkpython.ahk:
#Persistent dllcall(A_ScriptParams, "int", 42, "cdecl int") return f1:: inputbox, x, enter a numerical parameter for python callback result := dllcall(A_ScriptParams, "int", x, "cdecl int") return
ahkpython.py
from ctypes import * ahk = cdll.AutoHotkey pyclient = create_string_buffer("ahkpython.ahk") # no unicode in ahk CMPFUNC = CFUNCTYPE(c_int, c_int) def py_cmp_func(a): print "ahk: " , a return a cmp_func = CMPFUNC(py_cmp_func) fx = create_string_buffer(str(cast(cmp_func, c_void_p).value)) script = create_string_buffer(""" fx2(msg){ WinActivate %msg% msgbox in function fx2 with %msg% from python return "success" } """) ahk.ahkdll(pyclient, "", fx) ahk.ahkassign(create_string_buffer("fx"), fx) ahk.addScript(script) ahk.ahkFunction(create_string_buffer("fx2"), create_string_buffer("Untitled"))
remarks:
create_string_buffer is required because autohotkey.dll exported functions do not work with unicode.
See HotkeyIt's excellent chm help file for documentation on the functions.
相关文章推荐
- 将 XML 和 Python结合起来
- 数字信封加密技术(RSA和DES结合起来的算法)
- 结合Python的SimpleHTTPServer源码来解析socket通信
- Python Cookbook 第二版 汉化版 [Recipe 16.4] 将参数与函数关联起来(Currying)
- 利用Python【Orange】结合DNA序列进行人种预测
- [python]subprocess与pyqt4结合使用以及编码问题
- 插件式开发怎样和三层架构结合起来?
- 浅要分析Python程序与C程序的结合使用
- [python学习]结合开源库学习python
- 【autoHotkey】 使用ahk读取内存判断魔兽争霸是否处于聊天状态
- 设计模式------------将工厂模式和策略模式结合起来
- 开始把准备把Exchange的一些基本操作和设置与SharePoint结合起来
- Python实现桶排序与快速排序算法结合应用示例
- 将lex,yacc(flex,bison)与MFC结合起来使用!
- 关于python调用zabbix api接口的自动化实例 [结合saltstack] 推荐
- [AHK]python调用ahk,并读取ahk的执行结果
- [AHK]AutoHotKey 快速下单脚本,支持东方财富,大智慧,通达信,同花顺
- python结合shell查询google关键词排名的实现代码
- expression将JS、Css结合起来
- expression将JS、Css结合起来