# com

作者: Sean 最近更新时间: 20100206

AutoHotkey does not provide native support for COM. With these functions it is possible to work with the COM. Now it is possible to automate the Internet Explorer.
From Wikipedia, the free encyclopedia:
(http://en.wikipedia.org/wiki/Component_Object_Model)
"Component Object Model (COM) is a binary-interface standard for software componentry introduced by Microsoft in 1993. It is used to enable interprocess communication and dynamic object creation in a large range of programming languages. The term COM is often used in the Microsoft software development industry as an umbrella term that encompasses the OLE, OLE Automation, ActiveX, COM+ and DCOM technologies."

COM_AccessibleChildren(pacc, cChildren, ByRef varChildren)
COM_AccessibleObjectFromEvent(hWnd, idObject, idChild, ByRef _idChild_="")
COM_AccessibleObjectFromPoint(x, y, ByRef _idChild_="")
COM_AccessibleObjectFromWindow(hWnd, idObject=-4, IID = "")
COM_AccInit()
COM_AccTerm()
COM_ActiveXObject(ProgID)
COM_AddRef(ppv)
COM_Advise(pcp, psink)
COM_Ansi2Unicode(ByRef sString, ByRef wString, nSize = "")
COM_Ansi4Unicode(pString, nSize = "")
COM_AtlAxAttachControl(pdsp, hWnd, Version = "")
COM_AtlAxCreateContainer(hWnd, l, t, w, h, Name = "", Version = "")
COM_AtlAxCreateControl(hWnd, Name, Version = "")
COM_AtlAxGetContainer(pdsp, bCtrl = "")
COM_AtlAxGetControl(hWnd, Version = "")
COM_AtlAxGetHost(hWnd, Version = "")
COM_AtlAxWinInit(Version = "")
COM_AtlAxWinTerm(Version = "")
COM_CLSID4ProgID(ByRef CLSID, ProgID)
COM_CoCreateGuid()
COM_CoInitialize()
COM_ConnectObject(psource, prefix = "", DIID = "")
COM_CoTaskMemAlloc(cb)
COM_CoTaskMemFree(pv)
COM_CoUninitialize()
COM_CreateIDispatch()
COM_CreateObject(CLSID, IID = "", CLSCTX = 5)
COM_DisconnectObject(psink)
COM_DispGetParam(pDispParams, Position = 0, vt = 8)
COM_DispInterface(this, prm1="", prm2="", prm3="", prm4="", prm5="", prm6="", prm7="", prm8="")
COM_DispSetParam(val, pDispParams, Position = 0, vt = 8)
COM_Enumerate(penum, ByRef Result, ByRef vt = "")
COM_Error(hr = "", lr = "", pei = "", name = "")
COM_FindConnectionPoint(pdp, DIID)
COM_GetActiveObject(ProgID)
COM_GetConnectionInterface(pcp)
COM_GetDefaultEvents(pdisp)
COM_GetDefaultInterface(pdisp)
COM_GetGuidOfName(pdisp, Name)
COM_GetObject(Moniker)
COM_GetRoleText(nRole)
COM_GetStateText(nState)
COM_GetTypeInfoOfGuid(pdisp, GUID)
COM_GUID4String(ByRef CLSID, String)
COM_Init()
COM_Invoke(pdsp,name="",prm0="vT_NoNe",prm1="vT_NoNe",prm2="vT_NoNe",prm3="vT_NoNe",prm4="vT_NoNe",prm5="vT_NoNe",prm6="vT_NoNe",prm7="vT_NoNe",prm8="vT_NoNe",prm9="vT_NoNe")
COM_Invoke_(pdsp,name,typ0="",prm0="",typ1="",prm1="",typ2="",prm2="",typ3="",prm3="",typ4="",prm4="",typ5="",prm5="",typ6="",prm6="",typ7="",prm7="",typ8="",prm8="",typ9="",prm9="")
COM_IsEqualGUID(this+24,prm1)
COM_ProgID4CLSID(pCLSID)
COM_QueryInterface(ppv, IID = "")
COM_QueryService(ppv, SID, IID = "")
COM_Release(ppv)
COM_SafeArrayDestroy(psar)
COM_ScriptControl(sCode, sLang = "", bEval = False, sFunc = "", sName = "", pdisp = 0, bGlobal = False)
COM_String4GUID(pGUID)
COM_SysAllocString(astr)
COM_SysFreeString(bstr)
COM_SysString(ByRef wString, sString)
COM_SysStringLen(bstr)
COM_Term()
COM_Unadvise(pcp, nCookie)
COM_Unicode2Ansi(ByRef wString, ByRef sString, nSize = "")
COM_Unicode4Ansi(ByRef wString, sString, nSize = "")
COM_VariantChangeType(pvarDst, pvarSrc, vt = 8)
COM_VariantClear(pvar)
COM_VTable(ppv, idx)
COM_WindowFromAccessibleObject(pacc)

关于函数的参数和返回值, 请参阅其源码或 此文档.

#### 备注

Requires Ahk Version 1.0.47.00.
Some tutorials:
o http://www.autohotkey.com/forum/viewtopic.php?t=34972 (by tank)
o http://www.autohotkey.com/forum/viewtopic.php?t=51020 (by jethrow)

关于此函数(集)的更新细节和注意事项, 请参见 AutoHotkey 论坛: http://www.autohotkey.com/forum/topic22923.html

#### 许可

不存在

#### 示例

    ; #Include com.ahk
    #NoEnv
    SendMode Input
    SetWorkingDir %A_ScriptDir%

    COM_Init()
    pwb := COM_CreateObject("InternetExplorer.Application")
    COM_Invoke(pwb , "Visible=", "True") ;"False" ;"True" ;
    url:="http://www.google.com"
    COM_Invoke(pwb, "Navigate", url)
    loop
          If (rdy:=COM_Invoke(pwb,"readyState") = 4)
             break
    url:="http://www.Yahoo.com"
    COM_Invoke(pwb, "Navigate", url)
    loop
          If (rdy:=COM_Invoke(pwb,"readyState") = 4)
             break
    MsgBox, 262208, Done, Goodbye,5
    COM_Invoke(pwb, "Quit")
    COM_Term()