Versions Compared


  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3
Code Block
import System.Threading
import System.Reflection

def CreateInstance(progid):
	type = System.Type.GetTypeFromProgID(progid)
	return type()

def SetProperty(target, name, value):
	target.GetType().InvokeMember(name, BindingFlags.SetProperty, null, target, (value,))

def GetProperty(target, name):
	return target.GetType().InvokeMember(name, BindingFlags.GetProperty, null, target, null)

def Invoke(target, name, arg):
	return target.GetType().InvokeMember(name, BindingFlags.InvokeMethod, null, target, (arg,))

ie = CreateInstance("InternetExplorer.Application")
SetProperty(ie, "Visible", true)
Invoke(ie, "Navigate2", "")

Thread.Sleep(50ms) while GetProperty(ie, "Busy")

document = GetProperty(ie, "Document")
print("$(GetProperty(document, 'title')) is $(GetProperty(document, 'fileSize')) bytes long.")

Alternatively, one could use the tlbimp utility included with the .net framework sdk to generate an interop assembly from the Internet Explorer type library.