[python与aardio] 在py中使用aardio com接口
By
mouse
at 2021-10-15 • 1人收藏 • 1291人看过
python虽有win32com相关库, 但有各种版本问题, 试了好久没搞定,最后决定使用aardio的com, 发现用起来非常方便, 故分享下
import console import com; console.open() import py3; var objs = {}; py3.export.aardio = { create = function(name){objs[name] = com.CreateObject(name)}; call = λ(objName, fnName, ...) objs[objName][fnName](...); } py3.exec(` import os,aardio class aardioCom: def __init__(self, objName): self.objName = objName aardio.create(objName) def __getattr__(self, fnName): return lambda *args: aardio.call(self.objName, fnName, *args) dm = aardioCom("dm.dmsoft");#创建大漠对象, 需要先注册 dm.moveTo(200,700) #移动鼠标看看 path = r'c:\tmp.png' #截图并查看 dm.CapturePng(0,0,2000,2000,path) os.system(path) wsh = aardioCom("wscript.shell") wsh.exec("notepad") #运行记事本 fs = aardioCom("Scripting.FileSystemObject") fs.DeleteFile(path) #删除图片 `) console.pause(true);
3 个回复 | 最后更新于 2021-10-26
登录后方可回帖
其实还可以这样玩,把整个窗体文件扔进一个大的函数里,放在py3.export中,然后也是可以在py3中直接运行原有窗体程序的,虽然好像没什么作用。![](/static/editor/dialogs/emotion/images/pp/i_f02.png)