func main() { ole.CoInitialize(0) unknown, _ := oleutil.CreateObject("Agent.Control.1") agent, _ := unknown.QueryInterface(ole.IID_IDispatch) oleutil.PutProperty(agent, "Connected", true) characters := oleutil.MustGetProperty(agent, "Characters").ToIDispatch() oleutil.CallMethod(characters, "Load", "Merlin", "c:\\windows\\msagent\\chars\\Merlin.acs") character := oleutil.MustCallMethod(characters, "Character", "Merlin").ToIDispatch() oleutil.CallMethod(character, "Show") oleutil.CallMethod(character, "Speak", "こんにちわ世界") time.Sleep(4000000000) }
func main() { ole.CoInitialize(0) unknown, _ := oleutil.CreateObject("InternetExplorer.Application") ie, _ := unknown.QueryInterface(ole.IID_IDispatch) oleutil.CallMethod(ie, "Navigate", "http://www.google.com") oleutil.PutProperty(ie, "Visible", true) for { if oleutil.MustGetProperty(ie, "Busy").Val == 0 { break } } time.Sleep(1e9) document := oleutil.MustGetProperty(ie, "document").ToIDispatch() window := oleutil.MustGetProperty(document, "parentWindow").ToIDispatch() // set 'golang' to text box. oleutil.MustCallMethod(window, "eval", "document.getElementsByName('q')[0].value = 'golang'") // click btnG. btnG := oleutil.MustCallMethod(window, "eval", "document.getElementsByName('btnG')[0]").ToIDispatch() oleutil.MustCallMethod(btnG, "click") }