from win32com.client import Dispatch
#ref : http://mow001.blogspot.com/2006/03/vbscript-hosting-in-msh-inputbox-in.html
vbs = Dispatch("MSScriptControl.ScriptControl")
vbs.Language = "vbscript";
code = """
function Input()
Input = inputbox("message","titre")
end function
function add(x,y)
add = x + y
end function
"""
vbs.addcode(code)
txt = vbs.eval('Input()')
print txt
somme = vbs.eval('add(2,3)')
vbs.ExecuteStatement('msgbox "The result is %d",,"Call VBS Add from Python"'%somme)
#ref : http://mow001.blogspot.com/2006/03/vbscript-hosting-in-msh-inputbox-in.html
vbs = Dispatch("MSScriptControl.ScriptControl")
vbs.Language = "vbscript";
code = """
function Input()
Input = inputbox("message","titre")
end function
function add(x,y)
add = x + y
end function
"""
vbs.addcode(code)
txt = vbs.eval('Input()')
print txt
somme = vbs.eval('add(2,3)')
vbs.ExecuteStatement('msgbox "The result is %d",,"Call VBS Add from Python"'%somme)
Powered by ScribeFire.
No comments:
Post a Comment