I'm trying to write a Python script with a GUI that, when I push a button, will execute a iMacros script. That's literally pretty much it, and after a lot of Googling and searching SO, I can't find it. I don't need help with the gui or anything, just how do I make iMacros run within/because of a python function?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
import os
os.system('"C:\Program Files\iOpus\iMacros\iMacros.exe" -macro my_macro.iim')
http://wiki.imacros.net/Example-Batchfile.bat
or
import win32com.client
def Hello():
import win32com.client
w=win32com.client.Dispatch("imacros")
w.iimInit("", 1)
w.iimPlay("Demo\\FillForm")
if __name__=='__main__':
Hello()
http://wiki.imacros.net/Python
see also: http://wiki.imacros.net/Sample_Code
The rub is that these methods will require the business or enterprise editions of imacros
( http://www.iopus.com/imacros/compare/)
You can alternatly use Autoit ( http://www.autoitscript.com/site/autoit/) to script opening of web browser and selecting a (imacro)script and running it by clicking play and you can use autoits python bindings even on the free version :)
回答2:
I figured out how to do this in chrome using python.
See: https://imgur.com/a/iJOe0
Actual reference is here: https://wiki.imacros.net/iMacros_for_Chrome (under comand line support)
After you have followed those instructions, simply do this in python:
import os
macro =r"C:\your\full\file\directory\and\file\name.html"
os.startfile(macro)