<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Серый форум &mdash; AHK_L: Ошибка при повторной попытке вывода инфы из некоторых окон]]></title>
		<link>https://forum.script-coding.com/viewtopic.php?id=6487</link>
		<atom:link href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=6487&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[Недавние сообщения в теме «AHK_L: Ошибка при повторной попытке вывода инфы из некоторых окон».]]></description>
		<lastBuildDate>Sun, 27 Nov 2011 20:41:52 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: AHK_L: Ошибка при повторной попытке вывода инфы из некоторых окон]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=53971#p53971</link>
			<description><![CDATA[<p>Спасибо!</p>]]></description>
			<author><![CDATA[null@example.com (DD)]]></author>
			<pubDate>Sun, 27 Nov 2011 20:41:52 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=53971#p53971</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK_L: Ошибка при повторной попытке вывода инфы из некоторых окон]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=53970#p53970</link>
			<description><![CDATA[<div class="quotebox"><cite>DD пишет:</cite><blockquote><p>Проверьте у себя, <strong>Александр_</strong>, — работает ли?</p></blockquote></div><p>Работает.</p>]]></description>
			<author><![CDATA[null@example.com (Александр_)]]></author>
			<pubDate>Sun, 27 Nov 2011 20:36:54 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=53970#p53970</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK_L: Ошибка при повторной попытке вывода инфы из некоторых окон]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=53967#p53967</link>
			<description><![CDATA[<p>Стоило мне закомментировать (благодаря какому-то внезапно-случайному наитию) ссылку на функцию<br /></p><div class="codebox"><pre><code>COM_AccTerm()</code></pre></div><p>— судя по всему и вызывавшую ошибку, — все заработало.<br />Проверьте у себя, <strong>Александр_</strong>, — работает ли?</p><p>Обновил первый пост.</p>]]></description>
			<author><![CDATA[null@example.com (DD)]]></author>
			<pubDate>Sun, 27 Nov 2011 20:23:17 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=53967#p53967</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK_L: Ошибка при повторной попытке вывода инфы из некоторых окон]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=53924#p53924</link>
			<description><![CDATA[<div class="quotebox"><cite>DD пишет:</cite><blockquote><p>И, <strong>Александр_</strong>, — по командной строке циферки где бы выведать?</p></blockquote></div><p>там же- смещение 64. <a href="http://undocumented.ntinternals.net/UserMode/Structures/RTL_USER_PROCESS_PARAMETERS.html">Тут</a> полное описание структуры, смещения считать очень просто- ULONG, PVOID и HANDLE занимают по 4 байта, а UNICODE_STRING 8 байт(всё верно для x86). смещение первого элемента равно нулю, смещение второго равно смещению первого плюс размер первого, смещение n-го равно смещению (n-1)-го плюс размер (n-1)-го.</p>]]></description>
			<author><![CDATA[null@example.com (Александр_)]]></author>
			<pubDate>Sun, 27 Nov 2011 09:40:24 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=53924#p53924</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK_L: Ошибка при повторной попытке вывода инфы из некоторых окон]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=53917#p53917</link>
			<description><![CDATA[<p>Код по ссылке работает!</p><div class="codebox"><pre><code>;
#SingleInstance Force

;константы
ProcessBasicInformation   := 0
PROCESS_QUERY_INFORMATION := 0x0400
PROCESS_VM_READ           := 0x0010
;функции
;открытие процесса
OpenProcess(dwDesiredAccess, bInheritHandle, dwProcessId)
{
   return DllCall(&quot;OpenProcess&quot;, &quot;uint&quot;, dwDesiredAccess, &quot;int&quot;, bInheritHandle, &quot;uint&quot;, dwProcessId, &quot;uint&quot;)
}
;получение информации о процессе
ZwQueryInformationProcess(ProcessHandle, ProcessInformationClass, ProcessInformation, ProcessInformationLength, ReturnLength)
{
   return DllCall(&quot;ntdll.dll\ZwQueryInformationProcess&quot;,&quot;uint&quot;, ProcessHandle, &quot;uint&quot;, ProcessInformationClass, &quot;uint&quot;, ProcessInformation, &quot;uint&quot;, ProcessInformationLength, &quot;uint&quot;, ReturnLength, &quot;uint&quot;)
}
;чтение данных из процесса
ReadProcessMemory(hProcess, lpBaseAddress, lpBuffer, nSize, lpNumberOfBytesRead)
{
   return DllCall(&quot;ReadProcessMemory&quot;, &quot;uint&quot;, hProcess, &quot;uint&quot;, lpBaseAddress, &quot;uint&quot;, lpBuffer, &quot;uint&quot;, nSize, &quot;uint&quot;, lpNumberOfBytesRead)
}


F5::
  WinGet, PID_Target, PID, % &quot;ahk_id &quot; WinExist(&quot;A&quot;)
  Exe_Path := % GetProcCurrentDirectory(PID_Target) ;%

  If WinActive(&quot;ahk_class IEFrame&quot;) || WinActive(&quot;ahk_class HH Parent&quot;)
  {
    IfWinActive, ahk_class IEFrame
      ControlGet, hwnd, hwnd, , Internet Explorer_Server1, ahk_class IEFrame

    IfWinActive, ahk_class HH Parent
      ControlGet, hwnd, hwnd, , Internet Explorer_Server1, ahk_class HH Parent

    Gosub, Get_Chm_IE_Path
    File_Path = %pthValue%
  }

  File_Path = %File_Path% ; избавляемся от возможных пробелов в начале строки

  msgbox 1 %Exe_Path%`n2 %File_Path%
Return

Get_Chm_IE_Path:
  ;see COM.ahk Standard Library   by Sean   http://www.autohotkey.com/forum/topic22923.html
  ;from: Capture Text from Read Only List
  COM_AccInit()
  If   pacc :=   COM_AccessibleObjectFromWindow(hWnd)
  {
     Loop, %   COM_AccessibleChildren(pacc, COM_Invoke(pacc,&quot;accChildCount&quot;), varChildren)
     If   paccChild:=NumGet(varChildren,16*A_Index-8)
     ttlName :=COM_Invoke(paccChild,&quot;accName&quot;,0)
     pthValue :=COM_Invoke(paccChild,&quot;accValue&quot;,0)
        , COM_Release(paccChild)
     COM_Release(pacc)
  }
  COM_AccTerm()

  If WinActive(&quot;ahk_class OpusApp&quot;) ; Word
  {
    COM_Init()
    Word := COM_GetActiveObject(&quot;Word.Application&quot;)
    ActiveDocument := com_invoke(Word,&quot;ActiveDocument&quot;)
    pthValue := COM_Invoke(ActiveDocument, &quot;Path&quot;) . &quot;\&quot; . COM_Invoke(ActiveDocument, &quot;Name&quot;)
  }
Return


;получает текущую директорию процесса по его PID&#039;у
GetProcCurrentDirectory(pid)
{
   global ProcessBasicInformation, PROCESS_QUERY_INFORMATION, PROCESS_VM_READ
   hProc := OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, 0, pid)
   if (hProc=0)
   {
      return Error
   }
   VarSetCapacity(ProcessInformation, 0x18) ; под PROCESS_BASIC_INFORMATION
   VarSetCapacity(Buffer, 8)
   VarSetCapacity(ReturnLength, 4) ; формальность
   ZwQueryInformationProcess(hProc, ProcessBasicInformation, &amp;ProcessInformation, 0x18, &amp;ReturnLength)
   ;по смещению 4 располагается адрес PEB
   ReadProcessMemory(hProc, NumGet(&amp;ProcessInformation, 4)+16, &amp;Buffer, 4, &amp;ReturnLength)
   ;по смещению 16 в PEB находится адрес структуры RTL_USER_PROCESS_PARAMETERS
   ReadProcessMemory(hProc, NumGet(&amp;Buffer)+56, &amp;Buffer, 8, &amp;ReturnLength)
   ; слово по смещению 0 содержит длину строки в байтах
   ; двойное слово по смещению 4 содержит адрес строки
   ; строка НЕ заканчивается нулём
   x:=NumGet(&amp;Buffer, 0, &quot;ushort&quot;)
   VarSetCapacity(str, x) ; выделяем необходимое место
   ReadProcessMemory(hProc, NumGet(&amp;Buffer, 4), &amp;str, x, &amp;ReturnLength)
   x:=StrGet(&amp;str, x/2, &quot;UTF-16&quot;)
 
   VarSetCapacity(ProcessInformation, 0) ; освобождаем память
   VarSetCapacity(str, 0)
   VarSetCapacity(Buffer, 0)
   VarSetCapacity(ReturnLength, 0)
   return x
}


;------------------------------------------------------------------------------
; COM.ahk Standard Library
; by Sean
; http://www.autohotkey.com/forum/topic22923.html
;------------------------------------------------------------------------------

COM_Init(bUn = &quot;&quot;)
{
    Static    h
    Return    (bUn&amp;&amp;!h:=&quot;&quot;)||h==&quot;&quot;&amp;&amp;1==(h:=DllCall(&quot;ole32\OleInitialize&quot;,&quot;Uint&quot;,0))?DllCall(&quot;ole32\OleUninitialize&quot;):0
}

COM_Term()
{
    COM_Init(1)
}

COM_VTable(ppv, idx)
{
    Return    NumGet(NumGet(1*ppv)+4*idx)
}

COM_QueryInterface(ppv, IID = &quot;&quot;)
{
    If    DllCall(NumGet(NumGet(1*ppv:=COM_Unwrap(ppv))), &quot;Uint&quot;, ppv+0, &quot;Uint&quot;, COM_GUID4String(IID,IID ? IID:IID=0 ? &quot;{00000000-0000-0000-C000-000000000046}&quot;:&quot;{00020400-0000-0000-C000-000000000046}&quot;), &quot;UintP&quot;, ppv:=0)=0
    Return    ppv
}

COM_AddRef(ppv)
{
    Return    DllCall(NumGet(NumGet(1*ppv:=COM_Unwrap(ppv))+4), &quot;Uint&quot;, ppv)
}

COM_Release(ppv)
{
    If Not    IsObject(ppv)
    Return    DllCall(NumGet(NumGet(1*ppv)+8), &quot;Uint&quot;, ppv)
    Else
    {
    nRef:=    DllCall(NumGet(NumGet(COM_Unwrap(ppv))+8), &quot;Uint&quot;, COM_Unwrap(ppv)), nRef==0 ? (ppv.prm_:=0):&quot;&quot;
    Return    nRef
    }
}

COM_QueryService(ppv, SID, IID = &quot;&quot;)
{
    If    DllCall(NumGet(NumGet(1*ppv:=COM_Unwrap(ppv))), &quot;Uint&quot;, ppv, &quot;Uint&quot;, COM_GUID4String(IID_IServiceProvider,&quot;{6D5140C1-7436-11CE-8034-00AA006009FA}&quot;), &quot;UintP&quot;, psp)=0
    &amp;&amp;    DllCall(NumGet(NumGet(1*psp)+12), &quot;Uint&quot;, psp, &quot;Uint&quot;, COM_GUID4String(SID,SID), &quot;Uint&quot;, IID ? COM_GUID4String(IID,IID):&amp;SID, &quot;UintP&quot;, ppv:=0)+DllCall(NumGet(NumGet(1*psp)+8), &quot;Uint&quot;, psp)*0=0
    Return    COM_Enwrap(ppv)
}

COM_FindConnectionPoint(pdp, DIID)
{
    DllCall(NumGet(NumGet(1*pdp)+ 0), &quot;Uint&quot;, pdp, &quot;Uint&quot;, COM_GUID4String(IID_IConnectionPointContainer, &quot;{B196B284-BAB4-101A-B69C-00AA00341D07}&quot;), &quot;UintP&quot;, pcc)
    DllCall(NumGet(NumGet(1*pcc)+16), &quot;Uint&quot;, pcc, &quot;Uint&quot;, COM_GUID4String(DIID,DIID), &quot;UintP&quot;, pcp)
    DllCall(NumGet(NumGet(1*pcc)+ 8), &quot;Uint&quot;, pcc)
    Return    pcp
}

COM_GetConnectionInterface(pcp)
{
    VarSetCapacity(DIID,16,0)
    DllCall(NumGet(NumGet(1*pcp)+12), &quot;Uint&quot;, pcp, &quot;Uint&quot;, &amp;DIID)
    Return    COM_String4GUID(&amp;DIID)
}

COM_Advise(pcp, psink)
{
    DllCall(NumGet(NumGet(1*pcp)+20), &quot;Uint&quot;, pcp, &quot;Uint&quot;, psink, &quot;UintP&quot;, nCookie)
    Return    nCookie
}

COM_Unadvise(pcp, nCookie)
{
    Return    DllCall(NumGet(NumGet(1*pcp)+24), &quot;Uint&quot;, pcp, &quot;Uint&quot;, nCookie)
}

COM_Enumerate(penum, ByRef Result, ByRef vt = &quot;&quot;)
{
    VarSetCapacity(varResult,16,0)
    If (0 =    hr:=DllCall(NumGet(NumGet(1*penum:=COM_Unwrap(penum))+12), &quot;Uint&quot;, penum, &quot;Uint&quot;, 1, &quot;Uint&quot;, &amp;varResult, &quot;UintP&quot;, 0))
    Result:=(vt:=NumGet(varResult,0,&quot;Ushort&quot;))=9||vt=13?COM_Enwrap(NumGet(varResult,8),vt):vt=8||vt&lt;0x1000&amp;&amp;COM_VariantChangeType(&amp;varResult,&amp;varResult)=0?StrGet(NumGet(varResult,8)) . COM_VariantClear(&amp;varResult):NumGet(varResult,8)
    Return    hr
}

COM_Invoke(pdsp,name=&quot;&quot;,prm0=&quot;vT_NoNe&quot;,prm1=&quot;vT_NoNe&quot;,prm2=&quot;vT_NoNe&quot;,prm3=&quot;vT_NoNe&quot;,prm4=&quot;vT_NoNe&quot;,prm5=&quot;vT_NoNe&quot;,prm6=&quot;vT_NoNe&quot;,prm7=&quot;vT_NoNe&quot;,prm8=&quot;vT_NoNe&quot;,prm9=&quot;vT_NoNe&quot;)
{
    pdsp :=    COM_Unwrap(pdsp)
    If    name=
    Return    DllCall(NumGet(NumGet(1*pdsp)+8),&quot;Uint&quot;,pdsp)
    If    name contains .
    {
        SubStr(name,1,1)!=&quot;.&quot; ? name.=&quot;.&quot;:name:=SubStr(name,2) . &quot;.&quot;
    Loop,    Parse,    name, .
    {
    If    A_Index=1
    {
        name :=    A_LoopField
        Continue
    }
    Else If    name not contains [,(
        prmn :=    &quot;&quot;
    Else If    InStr(&quot;])&quot;,SubStr(name,0))
    Loop,    Parse,    name, [(,&#039;&quot;)]
    If    A_Index=1
        name :=    A_LoopField
    Else    prmn :=    A_LoopField
    Else
    {
        name .=    &quot;.&quot; . A_LoopField
        Continue
    }
    If    A_LoopField!=
        pdsp:=    COM_Invoke(pdsp,name,prmn!=&quot;&quot; ? prmn:&quot;vT_NoNe&quot;),name:=A_LoopField
    Else    Return    prmn!=&quot;&quot;?COM_Invoke(pdsp,name,prmn,prm0,prm1,prm2,prm3,prm4,prm5,prm6,prm7,prm8):COM_Invoke(pdsp,name,prm0,prm1,prm2,prm3,prm4,prm5,prm6,prm7,prm8,prm9)
    }
    }
    Static    varg,namg,iidn,varResult,sParams
    VarSetCapacity(varResult,64,0),sParams?&quot;&quot;:(sParams:=&quot;0123456789&quot;,VarSetCapacity(varg,160,0),VarSetCapacity(namg,88,0),VarSetCapacity(iidn,16,0)),mParams:=0,nParams:=10,nvk:=3
    Loop,     Parse,    sParams
    If    (prm%A_LoopField%==&quot;vT_NoNe&quot;)
    {
         nParams:=A_Index-1
        Break
    }
    Else If    prm%A_LoopField% is integer
        NumPut(SubStr(prm%A_LoopField%,1,1)=&quot;+&quot;?9:prm%A_LoopField%==&quot;-0&quot;?(prm%A_LoopField%:=0x80020004)*0+10:3,NumPut(prm%A_LoopField%,varg,168-16*A_Index),-12)
    Else If    IsObject(prm%A_LoopField%)
        typ:=prm%A_LoopField%[&quot;typ_&quot;],prm:=prm%A_LoopField%[&quot;prm_&quot;],typ+0==&quot;&quot;?(NumPut(&amp;_nam_%A_LoopField%:=typ,namg,84-4*mParams++),typ:=prm%A_LoopField%[&quot;nam_&quot;]+0==&quot;&quot;?prm+0==&quot;&quot;||InStr(prm,&quot;.&quot;)?8:3:prm%A_LoopField%[&quot;nam_&quot;]):&quot;&quot;,NumPut(typ==8?COM_SysString(prm%A_LoopField%,prm):prm,NumPut(typ,varg,160-16*A_Index),4)
    Else    NumPut(COM_SysString(prm%A_LoopField%,prm%A_LoopField%),NumPut(8,varg,160-16*A_Index),4)
    If    nParams
        SubStr(name,0)=&quot;=&quot;?(name:=SubStr(name,1,-1),nvk:=12,NumPut(-3,namg,4)):&quot;&quot;,NumPut(nvk==12?1:mParams,NumPut(nParams,NumPut(&amp;namg+4,NumPut(&amp;varg+160-16*nParams,varResult,16))))
    Global    COM_HR, COM_LR:=&quot;&quot;
    If    (COM_HR:=DllCall(NumGet(NumGet(1*pdsp)+20),&quot;Uint&quot;,pdsp,&quot;Uint&quot;,&amp;iidn,&quot;Uint&quot;,NumPut(&amp;name,namg,84-4*mParams)-4,&quot;Uint&quot;,1+mParams,&quot;Uint&quot;,1024,&quot;Uint&quot;,&amp;namg,&quot;Uint&quot;))=0&amp;&amp;(COM_HR:=DllCall(NumGet(NumGet(1*pdsp)+24),&quot;Uint&quot;,pdsp,&quot;int&quot;,NumGet(namg),&quot;Uint&quot;,&amp;iidn,&quot;Uint&quot;,1024,&quot;Ushort&quot;,nvk,&quot;Uint&quot;,&amp;varResult+16,&quot;Uint&quot;,&amp;varResult,&quot;Uint&quot;,&amp;varResult+32,&quot;Uint&quot;,0,&quot;Uint&quot;))!=0&amp;&amp;nParams&amp;&amp;nvk&lt;4&amp;&amp;NumPut(-3,namg,4)&amp;&amp;(COM_LR:=DllCall(NumGet(NumGet(1*pdsp)+24),&quot;Uint&quot;,pdsp,&quot;int&quot;,NumGet(namg),&quot;Uint&quot;,&amp;iidn,&quot;Uint&quot;,1024,&quot;Ushort&quot;,12,&quot;Uint&quot;,NumPut(1,varResult,28)-16,&quot;Uint&quot;,0,&quot;Uint&quot;,0,&quot;Uint&quot;,0,&quot;Uint&quot;))=0
        COM_HR:=0
    Global    COM_VT:=NumGet(varResult,0,&quot;Ushort&quot;)
    Return    COM_HR=0?COM_VT&gt;1?COM_VT=9||COM_VT=13?COM_Enwrap(NumGet(varResult,8),COM_VT):COM_VT=8||COM_VT&lt;0x1000&amp;&amp;COM_VariantChangeType(&amp;varResult,&amp;varResult)=0?StrGet(NumGet(varResult,8)) . COM_VariantClear(&amp;varResult):NumGet(varResult,8):&quot;&quot;:COM_Error(COM_HR,COM_LR,&amp;varResult+32,name)
}

COM_InvokeSet(pdsp,name,prm0,prm1=&quot;vT_NoNe&quot;,prm2=&quot;vT_NoNe&quot;,prm3=&quot;vT_NoNe&quot;,prm4=&quot;vT_NoNe&quot;,prm5=&quot;vT_NoNe&quot;,prm6=&quot;vT_NoNe&quot;,prm7=&quot;vT_NoNe&quot;,prm8=&quot;vT_NoNe&quot;,prm9=&quot;vT_NoNe&quot;)
{
    Return    COM_Invoke(pdsp,name &quot;=&quot;,prm0,prm1,prm2,prm3,prm4,prm5,prm6,prm7,prm8,prm9)
}

COM_DispInterface(this, prm1=&quot;&quot;, prm2=&quot;&quot;, prm3=&quot;&quot;, prm4=&quot;&quot;, prm5=&quot;&quot;, prm6=&quot;&quot;, prm7=&quot;&quot;, prm8=&quot;&quot;)
{
    Critical
    If    A_EventInfo = 6
        hr:=DllCall(NumGet(NumGet(0+p:=NumGet(this+8))+28),&quot;Uint&quot;,p,&quot;Uint&quot;,prm1,&quot;UintP&quot;,pname,&quot;Uint&quot;,1,&quot;UintP&quot;,0),hr==0?(sfn:=StrGet(this+40) . StrGet(pname),COM_SysFreeString(pname),%sfn%(prm5,this,prm6)):&quot;&quot;
    Else If    A_EventInfo = 5
        hr:=DllCall(NumGet(NumGet(0+p:=NumGet(this+8))+40),&quot;Uint&quot;,p,&quot;Uint&quot;,prm2,&quot;Uint&quot;,prm3,&quot;Uint&quot;,prm5)
    Else If    A_EventInfo = 4
        NumPut(0*hr:=0x80004001,prm3+0)
    Else If    A_EventInfo = 3
        NumPut(0,prm1+0)
    Else If    A_EventInfo = 2
        NumPut(hr:=NumGet(this+4)-1,this+4)
    Else If    A_EventInfo = 1
        NumPut(hr:=NumGet(this+4)+1,this+4)
    Else If    A_EventInfo = 0
        COM_IsEqualGUID(this+24,prm1)||InStr(&quot;{00020400-0000-0000-C000-000000000046}{00000000-0000-0000-C000-000000000046}&quot;,COM_String4GUID(prm1)) ? NumPut(NumPut(NumGet(this+4)+1,this+4)-8,prm2+0):NumPut(0*hr:=0x80004002,prm2+0)
    Return    hr
}

COM_DispGetParam(pDispParams, Position = 0, vt = 8)
{
    VarSetCapacity(varResult,16,0)
    DllCall(&quot;oleaut32\DispGetParam&quot;, &quot;Uint&quot;, pDispParams, &quot;Uint&quot;, Position, &quot;Ushort&quot;, vt, &quot;Uint&quot;, &amp;varResult, &quot;UintP&quot;, nArgErr)
    Return    (vt:=NumGet(varResult,0,&quot;Ushort&quot;))=8?StrGet(NumGet(varResult,8)) . COM_VariantClear(&amp;varResult):vt=9||vt=13?COM_Enwrap(NumGet(varResult,8),vt):NumGet(varResult,8)
}

COM_DispSetParam(val, pDispParams, Position = 0, vt = 8)
{
    Return    NumPut(vt=8?COM_SysAllocString(val):vt=9||vt=13?COM_Unwrap(val):val,NumGet(NumGet(pDispParams+0)+(NumGet(pDispParams+8)-Position)*16-8),0,vt=11||vt=2 ? &quot;short&quot;:&quot;int&quot;)
}

COM_Error(hr = &quot;&quot;, lr = &quot;&quot;, pei = &quot;&quot;, name = &quot;&quot;)
{
    Static    bDebug:=1
    If Not    pei
    {
    bDebug:=hr
    Global    COM_HR, COM_LR
    Return    COM_HR&amp;&amp;COM_LR ? COM_LR&lt;&lt;32|COM_HR:COM_HR
    }
    Else If    !bDebug
    Return
    hr ? (VarSetCapacity(sError,1022),VarSetCapacity(nError,62),DllCall(&quot;kernel32\FormatMessage&quot;,&quot;Uint&quot;,0x1200,&quot;Uint&quot;,0,&quot;Uint&quot;,hr&lt;&gt;0x80020009?hr:(bExcep:=1)*(hr:=NumGet(pei+28))?hr:hr:=NumGet(pei+0,0,&quot;Ushort&quot;)+0x80040200,&quot;Uint&quot;,0,&quot;str&quot;,sError,&quot;Uint&quot;,512,&quot;Uint&quot;,0),DllCall(&quot;kernel32\FormatMessage&quot;,&quot;Uint&quot;,0x2400,&quot;str&quot;,&quot;0x%1!p!&quot;,&quot;Uint&quot;,0,&quot;Uint&quot;,0,&quot;str&quot;,nError,&quot;Uint&quot;,32,&quot;UintP&quot;,hr)):sError:=&quot;No COM Dispatch Object!`n&quot;,lr?(VarSetCapacity(sError2,1022),VarSetCapacity(nError2,62),DllCall(&quot;kernel32\FormatMessage&quot;,&quot;Uint&quot;,0x1200,&quot;Uint&quot;,0,&quot;Uint&quot;,lr,&quot;Uint&quot;,0,&quot;str&quot;,sError2,&quot;Uint&quot;,512,&quot;Uint&quot;,0),DllCall(&quot;kernel32\FormatMessage&quot;,&quot;Uint&quot;,0x2400,&quot;str&quot;,&quot;0x%1!p!&quot;,&quot;Uint&quot;,0,&quot;Uint&quot;,0,&quot;str&quot;,nError2,&quot;Uint&quot;,32,&quot;UintP&quot;,lr)):&quot;&quot;
    MsgBox, 260, COM Error Notification, % &quot;Function Name:`t&quot;&quot;&quot; . name . &quot;&quot;&quot;`nERROR:`t&quot; . sError . &quot;`t(&quot; . nError . &quot;)&quot; . (bExcep ? SubStr(NumGet(pei+24) ? DllCall(NumGet(pei+24),&quot;Uint&quot;,pei) : &quot;&quot;,1,0) . &quot;`nPROG:`t&quot; . StrGet(NumGet(pei+4)) . COM_SysFreeString(NumGet(pei+4)) . &quot;`nDESC:`t&quot; . StrGet(NumGet(pei+8)) . COM_SysFreeString(NumGet(pei+8)) . &quot;`nHELP:`t&quot; . StrGet(NumGet(pei+12)) . COM_SysFreeString(NumGet(pei+12)) . &quot;,&quot; . NumGet(pei+16) : &quot;&quot;) . (lr ? &quot;`n`nERROR2:`t&quot; . sError2 . &quot;`t(&quot; . nError2 . &quot;)&quot; : &quot;&quot;) . &quot;`n`nWill Continue?&quot;
    IfMsgBox, No, Exit
}

COM_CreateIDispatch()
{
    Static    IDispatch
    If Not    VarSetCapacity(IDispatch)
    {
        VarSetCapacity(IDispatch,28,0),   nParams=3112469
        Loop,   Parse,   nParams
        NumPut(RegisterCallback(&quot;COM_DispInterface&quot;,&quot;&quot;,A_LoopField,A_Index-1),IDispatch,4*(A_Index-1))
    }
    Return &amp;IDispatch
}

COM_GetDefaultInterface(pdisp)
{
    DllCall(NumGet(NumGet(1*pdisp) +12), &quot;Uint&quot;, pdisp , &quot;UintP&quot;, ctinf)
    If    ctinf
    {
    DllCall(NumGet(NumGet(1*pdisp)+16), &quot;Uint&quot;, pdisp, &quot;Uint&quot; , 0, &quot;Uint&quot;, 1024, &quot;UintP&quot;, ptinf)
    DllCall(NumGet(NumGet(1*ptinf)+12), &quot;Uint&quot;, ptinf, &quot;UintP&quot;, pattr)
    DllCall(NumGet(NumGet(1*pdisp)+ 0), &quot;Uint&quot;, pdisp, &quot;Uint&quot; , pattr, &quot;UintP&quot;, ppv)
    DllCall(NumGet(NumGet(1*ptinf)+76), &quot;Uint&quot;, ptinf, &quot;Uint&quot; , pattr)
    DllCall(NumGet(NumGet(1*ptinf)+ 8), &quot;Uint&quot;, ptinf)
    If    ppv
    DllCall(NumGet(NumGet(1*pdisp)+ 8), &quot;Uint&quot;, pdisp),    pdisp := ppv
    }
    Return    pdisp
}

COM_GetDefaultEvents(pdisp)
{
    DllCall(NumGet(NumGet(1*pdisp)+16), &quot;Uint&quot;, pdisp, &quot;Uint&quot; , 0, &quot;Uint&quot;, 1024, &quot;UintP&quot;, ptinf)
    DllCall(NumGet(NumGet(1*ptinf)+12), &quot;Uint&quot;, ptinf, &quot;UintP&quot;, pattr)
    VarSetCapacity(IID,16),DllCall(&quot;kernel32\RtlMoveMemory&quot;,&quot;Uint&quot;,&amp;IID,&quot;Uint&quot;,pattr,&quot;Uint&quot;,16)
    DllCall(NumGet(NumGet(1*ptinf)+76), &quot;Uint&quot;, ptinf, &quot;Uint&quot; , pattr)
    DllCall(NumGet(NumGet(1*ptinf)+72), &quot;Uint&quot;, ptinf, &quot;UintP&quot;, ptlib, &quot;UintP&quot;, idx)
    DllCall(NumGet(NumGet(1*ptinf)+ 8), &quot;Uint&quot;, ptinf)
    Loop, %    DllCall(NumGet(NumGet(1*ptlib)+12), &quot;Uint&quot;, ptlib)
    {
        DllCall(NumGet(NumGet(1*ptlib)+20), &quot;Uint&quot;, ptlib, &quot;Uint&quot;, A_Index-1, &quot;UintP&quot;, TKind)
        If    TKind &lt;&gt; 5
            Continue
        DllCall(NumGet(NumGet(1*ptlib)+16), &quot;Uint&quot;, ptlib, &quot;Uint&quot;, A_Index-1, &quot;UintP&quot;, ptinf)
        DllCall(NumGet(NumGet(1*ptinf)+12), &quot;Uint&quot;, ptinf, &quot;UintP&quot;, pattr)
        nCount:=NumGet(pattr+48,0,&quot;Ushort&quot;)
        DllCall(NumGet(NumGet(1*ptinf)+76), &quot;Uint&quot;, ptinf, &quot;Uint&quot; , pattr)
        Loop, %    nCount
        {
            DllCall(NumGet(NumGet(1*ptinf)+36), &quot;Uint&quot;, ptinf, &quot;Uint&quot;, A_Index-1, &quot;UintP&quot;, nFlags)
            If    !(nFlags &amp; 1)
                Continue
            DllCall(NumGet(NumGet(1*ptinf)+32), &quot;Uint&quot;, ptinf, &quot;Uint&quot;, A_Index-1, &quot;UintP&quot;, hRefType)
            DllCall(NumGet(NumGet(1*ptinf)+56), &quot;Uint&quot;, ptinf, &quot;Uint&quot;, hRefType , &quot;UintP&quot;, prinf)
            DllCall(NumGet(NumGet(1*prinf)+12), &quot;Uint&quot;, prinf, &quot;UintP&quot;, pattr)
            nFlags &amp; 2 ? DIID:=COM_String4GUID(pattr) : bFind:=COM_IsEqualGUID(pattr,&amp;IID)
            DllCall(NumGet(NumGet(1*prinf)+76), &quot;Uint&quot;, prinf, &quot;Uint&quot; , pattr)
            DllCall(NumGet(NumGet(1*prinf)+ 8), &quot;Uint&quot;, prinf)
        }
        DllCall(NumGet(NumGet(1*ptinf)+ 8), &quot;Uint&quot;, ptinf)
        If    bFind
            Break
    }
    DllCall(NumGet(NumGet(1*ptlib)+ 8), &quot;Uint&quot;, ptlib)
    Return    bFind ? DIID : &quot;{00000000-0000-0000-0000-000000000000}&quot;
}

COM_GetGuidOfName(pdisp, Name)
{
    DllCall(NumGet(NumGet(1*pdisp)+16), &quot;Uint&quot;, pdisp, &quot;Uint&quot;, 0, &quot;Uint&quot;, 1024, &quot;UintP&quot;, ptinf)
    DllCall(NumGet(NumGet(1*ptinf)+72), &quot;Uint&quot;, ptinf, &quot;UintP&quot;, ptlib, &quot;UintP&quot;, idx)
    DllCall(NumGet(NumGet(1*ptinf)+ 8), &quot;Uint&quot;, ptinf), ptinf:=0
    DllCall(NumGet(NumGet(1*ptlib)+44), &quot;Uint&quot;, ptlib, &quot;Uint&quot;, &amp;Name, &quot;Uint&quot;, 0, &quot;UintP&quot;, ptinf, &quot;UintP&quot;, memID, &quot;UshortP&quot;, 1)
    DllCall(NumGet(NumGet(1*ptlib)+ 8), &quot;Uint&quot;, ptlib)
    DllCall(NumGet(NumGet(1*ptinf)+12), &quot;Uint&quot;, ptinf, &quot;UintP&quot;, pattr)
    GUID := COM_String4GUID(pattr)
    DllCall(NumGet(NumGet(1*ptinf)+76), &quot;Uint&quot;, ptinf, &quot;Uint&quot; , pattr)
    DllCall(NumGet(NumGet(1*ptinf)+ 8), &quot;Uint&quot;, ptinf)
    Return    GUID
}

COM_GetTypeInfoOfGuid(pdisp, GUID)
{
    DllCall(NumGet(NumGet(1*pdisp)+16), &quot;Uint&quot;, pdisp, &quot;Uint&quot;, 0, &quot;Uint&quot;, 1024, &quot;UintP&quot;, ptinf)
    DllCall(NumGet(NumGet(1*ptinf)+72), &quot;Uint&quot;, ptinf, &quot;UintP&quot;, ptlib, &quot;UintP&quot;, idx)
    DllCall(NumGet(NumGet(1*ptinf)+ 8), &quot;Uint&quot;, ptinf), ptinf := 0
    DllCall(NumGet(NumGet(1*ptlib)+24), &quot;Uint&quot;, ptlib, &quot;Uint&quot;, COM_GUID4String(GUID,GUID), &quot;UintP&quot;, ptinf)
    DllCall(NumGet(NumGet(1*ptlib)+ 8), &quot;Uint&quot;, ptlib)
    Return    ptinf
}

COM_ConnectObject(pdisp, prefix = &quot;&quot;, DIID = &quot;&quot;)
{
    pdisp:=    COM_Unwrap(pdisp)
    If Not    DIID
        0+(pconn:=COM_FindConnectionPoint(pdisp,&quot;{00020400-0000-0000-C000-000000000046}&quot;)) ? (DIID:=COM_GetConnectionInterface(pconn))=&quot;{00020400-0000-0000-C000-000000000046}&quot; ? DIID:=COM_GetDefaultEvents(pdisp):&quot;&quot;:pconn:=COM_FindConnectionPoint(pdisp,DIID:=COM_GetDefaultEvents(pdisp))
    Else    pconn:=COM_FindConnectionPoint(pdisp,SubStr(DIID,1,1)=&quot;{&quot; ? DIID:DIID:=COM_GetGuidOfName(pdisp,DIID))
    If    !pconn||!ptinf:=COM_GetTypeInfoOfGuid(pdisp,DIID)
    {
        MsgBox, No Event Interface Exists!
        Return
    }
    NumPut(pdisp,NumPut(ptinf,NumPut(1,NumPut(COM_CreateIDispatch(),0+psink:=COM_CoTaskMemAlloc(40+nSize:=StrLen(prefix)*2+2)))))
    DllCall(&quot;kernel32\RtlMoveMemory&quot;,&quot;Uint&quot;,psink+24,&quot;Uint&quot;,COM_GUID4String(DIID,DIID),&quot;Uint&quot;,16)
    DllCall(&quot;kernel32\RtlMoveMemory&quot;,&quot;Uint&quot;,psink+40,&quot;Uint&quot;,&amp;prefix,&quot;Uint&quot;,nSize)
    NumPut(COM_Advise(pconn,psink),NumPut(pconn,psink+16))
    Return    psink
}

COM_DisconnectObject(psink)
{
    Return    COM_Unadvise(NumGet(psink+16),NumGet(psink+20))=0 ? (0,COM_Release(NumGet(psink+16)),COM_Release(NumGet(psink+8)),COM_CoTaskMemFree(psink)):1
}

COM_CreateObject(CLSID, IID = &quot;&quot;, CLSCTX = 21)
{
    ppv :=    COM_CreateInstance(CLSID,IID,CLSCTX)
    Return    IID==&quot;&quot; ? COM_Enwrap(ppv):ppv
}

COM_GetObject(Name)
{
    COM_Init()
    If    DllCall(&quot;ole32\CoGetObject&quot;, &quot;Uint&quot;, &amp;Name, &quot;Uint&quot;, 0, &quot;Uint&quot;, COM_GUID4String(IID_IDispatch,&quot;{00020400-0000-0000-C000-000000000046}&quot;), &quot;UintP&quot;, pdisp)=0
    Return    COM_Enwrap(pdisp)
}

COM_GetActiveObject(CLSID)
{
    COM_Init()
    If    DllCall(&quot;oleaut32\GetActiveObject&quot;, &quot;Uint&quot;, COM_GUID4String(CLSID,CLSID), &quot;Uint&quot;, 0, &quot;UintP&quot;, punk)=0
    &amp;&amp;    DllCall(NumGet(NumGet(1*punk)), &quot;Uint&quot;, punk, &quot;Uint&quot;, COM_GUID4String(IID_IDispatch,&quot;{00020400-0000-0000-C000-000000000046}&quot;), &quot;UintP&quot;, pdisp)+DllCall(NumGet(NumGet(1*punk)+8), &quot;Uint&quot;, punk)*0=0
    Return    COM_Enwrap(pdisp)
}

COM_CreateInstance(CLSID, IID = &quot;&quot;, CLSCTX = 21)
{
    COM_Init()
    If    DllCall(&quot;ole32\CoCreateInstance&quot;, &quot;Uint&quot;, COM_GUID4String(CLSID,CLSID), &quot;Uint&quot;, 0, &quot;Uint&quot;, CLSCTX, &quot;Uint&quot;, COM_GUID4String(IID,IID ? IID:IID=0 ? &quot;{00000000-0000-0000-C000-000000000046}&quot;:&quot;{00020400-0000-0000-C000-000000000046}&quot;), &quot;UintP&quot;, ppv)=0
    Return    ppv
}

COM_CLSID4ProgID(ByRef CLSID, ProgID)
{
    VarSetCapacity(CLSID,16,0)
    DllCall(&quot;ole32\CLSIDFromProgID&quot;, &quot;Uint&quot;, &amp;ProgID, &quot;Uint&quot;, &amp;CLSID)
    Return    &amp;CLSID
}

COM_ProgID4CLSID(pCLSID)
{
    DllCall(&quot;ole32\ProgIDFromCLSID&quot;, &quot;Uint&quot;, pCLSID, &quot;UintP&quot;, pProgID)
    Return    StrGet(pProgID) . COM_CoTaskMemFree(pProgID)
}

COM_GUID4String(ByRef CLSID, String)
{
    VarSetCapacity(CLSID,16,0)
    DllCall(&quot;ole32\CLSIDFromString&quot;, &quot;Uint&quot;, &amp;String, &quot;Uint&quot;, &amp;CLSID)
    Return    &amp;CLSID
}

COM_String4GUID(pGUID)
{
    VarSetCapacity(String,38*2)
    DllCall(&quot;ole32\StringFromGUID2&quot;, &quot;Uint&quot;, pGUID, &quot;str&quot;, String, &quot;int&quot;, 39)
    Return    String
}

COM_IsEqualGUID(pGUID1, pGUID2)
{
    Return    DllCall(&quot;ole32\IsEqualGUID&quot;, &quot;Uint&quot;, pGUID1, &quot;Uint&quot;, pGUID2)
}

COM_CoCreateGuid()
{
    VarSetCapacity(GUID,16,0)
    DllCall(&quot;ole32\CoCreateGuid&quot;, &quot;Uint&quot;, &amp;GUID)
    Return    COM_String4GUID(&amp;GUID)
}

COM_CoInitialize()
{
    Return    DllCall(&quot;ole32\CoInitialize&quot;, &quot;Uint&quot;, 0)
}

COM_CoUninitialize()
{
        DllCall(&quot;ole32\CoUninitialize&quot;)
}

COM_CoTaskMemAlloc(cb)
{
    Return    DllCall(&quot;ole32\CoTaskMemAlloc&quot;, &quot;Uint&quot;, cb)
}

COM_CoTaskMemFree(pv)
{
        DllCall(&quot;ole32\CoTaskMemFree&quot;, &quot;Uint&quot;, pv)
}

COM_SysAllocString(str)
{
    Return    DllCall(&quot;oleaut32\SysAllocString&quot;, &quot;Uint&quot;, &amp;str)
}

COM_SysFreeString(pstr)
{
        DllCall(&quot;oleaut32\SysFreeString&quot;, &quot;Uint&quot;, pstr)
}

COM_SafeArrayDestroy(psar)
{
    Return    DllCall(&quot;oleaut32\SafeArrayDestroy&quot;, &quot;Uint&quot;, psar)
}

COM_VariantClear(pvar)
{
        DllCall(&quot;oleaut32\VariantClear&quot;, &quot;Uint&quot;, pvar)
}

COM_VariantChangeType(pvarDst, pvarSrc, vt = 8)
{
    Return    DllCall(&quot;oleaut32\VariantChangeTypeEx&quot;, &quot;Uint&quot;, pvarDst, &quot;Uint&quot;, pvarSrc, &quot;Uint&quot;, 1024, &quot;Ushort&quot;, 0, &quot;Ushort&quot;, vt)
}

COM_SysString(ByRef wString, sString)
{
    VarSetCapacity(wString,4+nLen:=2*StrLen(sString))
    Return    DllCall(&quot;kernel32\lstrcpyW&quot;,&quot;Uint&quot;,NumPut(nLen,wString),&quot;Uint&quot;,&amp;sString)
}

COM_AccInit()
{
    Static    h
    If Not    h
    COM_Init(), h:=DllCall(&quot;kernel32\LoadLibrary&quot;,&quot;str&quot;,&quot;oleacc&quot;)
}

COM_AccTerm()
{
    COM_Term()
}

COM_AccessibleChildren(pacc, cChildren, ByRef varChildren)
{
    VarSetCapacity(varChildren,cChildren*16,0)
    If    DllCall(&quot;oleacc\AccessibleChildren&quot;, &quot;Uint&quot;, COM_Unwrap(pacc), &quot;Uint&quot;, 0, &quot;Uint&quot;, cChildren+0, &quot;Uint&quot;, &amp;varChildren, &quot;UintP&quot;, cChildren:=0)=0
    Return    cChildren
}

COM_AccessibleObjectFromEvent(hWnd, idObject, idChild, ByRef _idChild_=&quot;&quot;)
{
    COM_AccInit(), VarSetCapacity(varChild,16,0)
    If    DllCall(&quot;oleacc\AccessibleObjectFromEvent&quot;, &quot;Uint&quot;, hWnd, &quot;Uint&quot;, idObject, &quot;Uint&quot;, idChild, &quot;UintP&quot;, pacc, &quot;Uint&quot;, &amp;varChild)=0
    Return    COM_Enwrap(pacc), _idChild_:=NumGet(varChild,8)
}

COM_AccessibleObjectFromPoint(x, y, ByRef _idChild_=&quot;&quot;)
{
    COM_AccInit(), VarSetCapacity(varChild,16,0)
    If    DllCall(&quot;oleacc\AccessibleObjectFromPoint&quot;, &quot;int&quot;, x, &quot;int&quot;, y, &quot;UintP&quot;, pacc, &quot;Uint&quot;, &amp;varChild)=0
    Return    COM_Enwrap(pacc), _idChild_:=NumGet(varChild,8)
}

COM_AccessibleObjectFromWindow(hWnd, idObject=-4, IID = &quot;&quot;)
{
    COM_AccInit()
    If    DllCall(&quot;oleacc\AccessibleObjectFromWindow&quot;, &quot;Uint&quot;, hWnd, &quot;Uint&quot;, idObject, &quot;Uint&quot;, COM_GUID4String(IID, IID ? IID : idObject&amp;0xFFFFFFFF==0xFFFFFFF0 ? &quot;{00020400-0000-0000-C000-000000000046}&quot;:&quot;{618736E0-3C3D-11CF-810C-00AA00389B71}&quot;), &quot;UintP&quot;, pacc)=0
    Return    COM_Enwrap(pacc)
}

COM_WindowFromAccessibleObject(pacc)
{
    If    DllCall(&quot;oleacc\WindowFromAccessibleObject&quot;, &quot;Uint&quot;, COM_Unwrap(pacc), &quot;UintP&quot;, hWnd)=0
    Return    hWnd
}

COM_GetRoleText(nRole)
{
    nLen:=    DllCall(&quot;oleacc\GetRoleTextW&quot;, &quot;Uint&quot;, nRole, &quot;Uint&quot;, 0, &quot;Uint&quot;, 0)
    VarSetCapacity(sRole,nLen*2)
    If    DllCall(&quot;oleacc\GetRoleTextW&quot;, &quot;Uint&quot;, nRole, &quot;str&quot;, sRole, &quot;Uint&quot;, nLen+1)
    Return    sRole
}

COM_GetStateText(nState)
{
    nLen:=    DllCall(&quot;oleacc\GetStateTextW&quot;, &quot;Uint&quot;, nState, &quot;Uint&quot;, 0, &quot;Uint&quot;, 0)
    VarSetCapacity(sState,nLen*2)
    If    DllCall(&quot;oleacc\GetStateTextW&quot;, &quot;Uint&quot;, nState, &quot;str&quot;, sState, &quot;Uint&quot;, nLen+1)
    Return    sState
}

COM_AtlAxWinInit(Version = &quot;&quot;)
{
    Static    h
    If Not    h
    COM_Init(), h:=DllCall(&quot;kernel32\LoadLibrary&quot;,&quot;str&quot;,&quot;atl&quot; . Version), DllCall(&quot;atl&quot; . Version . &quot;\AtlAxWinInit&quot;)
}

COM_AtlAxWinTerm(Version = &quot;&quot;)
{
    COM_Term()
}

COM_AtlAxGetHost(hWnd, Version = &quot;&quot;)
{
    If    DllCall(&quot;atl&quot; . Version . &quot;\AtlAxGetHost&quot;, &quot;Uint&quot;, hWnd, &quot;UintP&quot;, punk)=0
    Return    COM_Enwrap(COM_QueryInterface(punk)+COM_Release(punk)*0)
}

COM_AtlAxGetControl(hWnd, Version = &quot;&quot;)
{
    If    DllCall(&quot;atl&quot; . Version . &quot;\AtlAxGetControl&quot;, &quot;Uint&quot;, hWnd, &quot;UintP&quot;, punk)=0
    Return    COM_Enwrap(COM_QueryInterface(punk)+COM_Release(punk)*0)
}

COM_AtlAxAttachControl(pdsp, hWnd, Version = &quot;&quot;)
{
    If    DllCall(&quot;atl&quot; . Version . &quot;\AtlAxAttachControl&quot;, &quot;Uint&quot;, punk:=COM_QueryInterface(pdsp,0), &quot;Uint&quot;, hWnd, &quot;Uint&quot;, COM_AtlAxWinInit(Version))+COM_Release(punk)*0=0
    Return    COM_Enwrap(pdsp)
}

COM_AtlAxCreateControl(hWnd, Name, Version = &quot;&quot;)
{
    If    DllCall(&quot;atl&quot; . Version . &quot;\AtlAxCreateControl&quot;, &quot;Uint&quot;, &amp;Name, &quot;Uint&quot;, hWnd, &quot;Uint&quot;, 0, &quot;Uint&quot;, COM_AtlAxWinInit(Version))=0
    Return    COM_AtlAxGetControl(hWnd,Version)
}

COM_AtlAxCreateContainer(hWnd, l, t, w, h, Name = &quot;&quot;, Version = &quot;&quot;)
{
    Return    DllCall(&quot;user32\CreateWindowEx&quot;, &quot;Uint&quot;,0x200, &quot;str&quot;, &quot;AtlAxWin&quot; . Version, &quot;Uint&quot;, Name?&amp;Name:0, &quot;Uint&quot;, 0x54000000, &quot;int&quot;, l, &quot;int&quot;, t, &quot;int&quot;, w, &quot;int&quot;, h, &quot;Uint&quot;, hWnd, &quot;Uint&quot;, 0, &quot;Uint&quot;, 0, &quot;Uint&quot;, COM_AtlAxWinInit(Version))
}

COM_AtlAxGetContainer(pdsp, bCtrl = &quot;&quot;)
{
    DllCall(NumGet(NumGet(1*pdsp:=COM_Unwrap(pdsp))), &quot;Uint&quot;, pdsp, &quot;Uint&quot;, COM_GUID4String(IID_IOleWindow,&quot;{00000114-0000-0000-C000-000000000046}&quot;), &quot;UintP&quot;, pwin)
    DllCall(NumGet(NumGet(1*pwin)+12), &quot;Uint&quot;, pwin, &quot;UintP&quot;, hCtrl)
    DllCall(NumGet(NumGet(1*pwin)+ 8), &quot;Uint&quot;, pwin)
    Return    bCtrl?hCtrl:DllCall(&quot;user32\GetParent&quot;, &quot;Uint&quot;, hCtrl)
}

COM_ScriptControl(sCode, sEval = &quot;&quot;, sName = &quot;&quot;, Obj = &quot;&quot;, bGlobal = &quot;&quot;)
{
    oSC:=COM_CreateObject(&quot;ScriptControl&quot;), oSC.Language(sEval+0==&quot;&quot;?&quot;VBScript&quot;:&quot;JScript&quot;), sName&amp;&amp;Obj?oSC.AddObject(sName,Obj,bGlobal):&quot;&quot;
    Return    sEval?oSC.Eval(sEval+0?sCode:sEval oSC.AddCode(sCode)):oSC.ExecuteStatement(sCode)
}

COM_Parameter(typ, prm = &quot;&quot;, nam = &quot;&quot;)
{
    Return    IsObject(prm)?prm:Object(&quot;typ_&quot;,typ,&quot;prm_&quot;,prm,&quot;nam_&quot;,nam)
}

COM_Enwrap(obj, vt = 9)
{
    Static    base
    Return    IsObject(obj)?obj:Object(&quot;prm_&quot;,obj,&quot;typ_&quot;,vt,&quot;base&quot;,base?base:base:=Object(&quot;__Delete&quot;,&quot;COM_Invoke&quot;,&quot;__Call&quot;,&quot;COM_Invoke&quot;,&quot;__Get&quot;,&quot;COM_Invoke&quot;,&quot;__Set&quot;,&quot;COM_InvokeSet&quot;,&quot;base&quot;,Object(&quot;__Delete&quot;,&quot;COM_Term&quot;)))
}

COM_Unwrap(obj)
{
    Return    IsObject(obj)?obj.prm_:obj
}
;------------------------------------------------------------------------------
; END  COM.ahk Standard Library
;------------------------------------------------------------------------------</code></pre></div><p>Но, странно: получаемая адресная строка IE не обновляется при последующих нажатиях...<br />И, <strong>Александр_</strong>, — по командной строке циферки где бы выведать?</p>]]></description>
			<author><![CDATA[null@example.com (DD)]]></author>
			<pubDate>Sun, 27 Nov 2011 01:32:28 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=53917#p53917</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK_L: Ошибка при повторной попытке вывода инфы из некоторых окон]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=53915#p53915</link>
			<description><![CDATA[<div class="quotebox"><cite>DD пишет:</cite><blockquote><p>А может есть вариант получения не через <strong>ComObjGet</strong> — как-то иначе?</p></blockquote></div><p><a href="http://forum.script-coding.com/viewtopic.php?id=6443">пост 16</a>, таким образом можно почти любую информацию достать, конкретно расположение файла хранится в RTL_USER_PROCESS_PARAMETERS по смещению&nbsp; 56. Кстати, я там забыл хендл процесса закрыть.<br /></p><div class="quotebox"><cite>DD пишет:</cite><blockquote><p>Или некую переменную очищать на каком-то этапе?</p></blockquote></div><p>Нужно разбить эту строку на минимальные фрагменты и найти точное место ошибки. Переменную с pid&#039;ом тоже нужно проверить. Может это вообще из-за перевода строки <img src="//forum.script-coding.com/img/smilies/smile.png" width="15" height="15" />.</p>]]></description>
			<author><![CDATA[null@example.com (Александр_)]]></author>
			<pubDate>Sat, 26 Nov 2011 23:49:43 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=53915#p53915</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK_L: Ошибка при повторной попытке вывода инфы из некоторых окон]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=53914#p53914</link>
			<description><![CDATA[<p>А может есть вариант получения не через <strong>ComObjGet</strong> — как-то иначе?<br />Или некую переменную очищать на каком-то этапе?</p>]]></description>
			<author><![CDATA[null@example.com (DD)]]></author>
			<pubDate>Sat, 26 Nov 2011 23:20:05 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=53914#p53914</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK_L: Ошибка при повторной попытке вывода инфы из некоторых окон]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=53867#p53867</link>
			<description><![CDATA[<p><span class="postimg"><img src="http://s2.ipicture.ru/uploads/20111126/pkjxPq4Z.jpg" alt="http://s2.ipicture.ru/uploads/20111126/pkjxPq4Z.jpg" /></span><br /><em>xp SP2</em></p>]]></description>
			<author><![CDATA[null@example.com (DD)]]></author>
			<pubDate>Fri, 25 Nov 2011 23:06:59 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=53867#p53867</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK_L: Ошибка при повторной попытке вывода инфы из некоторых окон]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=53865#p53865</link>
			<description><![CDATA[<div class="quotebox"><cite>DD пишет:</cite><blockquote><p>По нажатии F5 выводятся пути, командные, адресные строки — Проводника, Рабочего стола, CHM-Справки, IE, Firefox`a.<br />Почему после нажатий в окнах IE или CHM-Справки — любое последующее заканчивается ошибкой?</p></blockquote></div><p>У меня всё нормально(win7 SP1).</p>]]></description>
			<author><![CDATA[null@example.com (Александр_)]]></author>
			<pubDate>Fri, 25 Nov 2011 22:45:02 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=53865#p53865</guid>
		</item>
		<item>
			<title><![CDATA[AHK_L: Ошибка при повторной попытке вывода инфы из некоторых окон]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=53863#p53863</link>
			<description><![CDATA[<p>По нажатии F5 выводятся пути, командные, адресные строки — Проводника, Рабочего стола, CHM-Справки, IE, Firefox`a.<br />Почему после нажатий в окнах IE или CHM-Справки — любое последующее заканчивается ошибкой?</p><p>Задействована COM-библ-ка.</p><div class="codebox"><pre><code>#SingleInstance Force

F5::
  WinGetActiveTitle, CurrentWin

  WinGetClass, CurrentWinClass, ahk_id %CurrentWinID%

  ControlGetText, WinEdit, Edit1, ahk_id %CurrentWinID%
  ;------------------------------------------------------

  PID_Target := WinExist( &quot;A&quot; ) ; получаем ID ОКНА
  If Not PID_Target ; если ОКНО не найдено...
  {
    MsgBox, Окно не найдено!
    Return ; конец скрипта
  }
  WinGet, PID_Target, PID, % &quot;ahk_id &quot; WinExist(&quot;A&quot;)
  Exe_Path := GetExecutablePath()
  If Not Exe_Path ; если что-то не так...
  {
    MsgBox, Процесс не существует, или к нему нет доступа
    Return ; конец скрипта
  }
  Com_Line := GetCommandLine() ; вызываем функцию получения ком. строки ОКНА
  If Not Com_Line ; если что-то не так...
  {
    MsgBox, Процесс не существует, или к нему нет доступа
    Return ; конец скрипта
  }
  StringReplace, File_Path, Com_Line, %Exe_Path% ; удаляем из строки путь к ОКНУ
  StringReplace, File_Path, File_Path, &quot;,, All ; удаляем из строки все кавычки, если они есть


  If WinActive(&quot;ahk_class Progman&quot;) || WinActive(&quot;ahk_class CabinetWClass&quot;)
    File_Path := GetDesktopExplorerDialogPath()

  If WinActive(&quot;ahk_class MozillaUIWindowClass&quot;)
  || WinActive(&quot;ahk_class MozillaWindowClass&quot;)
  {
    sData:=FF_RetrievePageName()
    Loop,Parse,sData,CSV 
       { 
       If A_Index = 1 
          sURL := A_LoopField 
       Else If A_Index = 2 
          sTitle := A_LoopField 
       }

    StringReplace, sData, sData, `&quot;`,`&quot;, `r`n, All
    StringTrimRight, sData, sData, 1
    StringTrimLeft, sData, sData, 1
    StringSplit, File_Path, sData,`n
    File_Path = %File_Path1%
  }

  If WinActive(&quot;ahk_class IEFrame&quot;) || WinActive(&quot;ahk_class HH Parent&quot;)
  {
    IfWinActive, ahk_class IEFrame
      ControlGet, hwnd, hwnd, , Internet Explorer_Server1, ahk_class IEFrame

    IfWinActive, ahk_class HH Parent
      ControlGet, hwnd, hwnd, , Internet Explorer_Server1, ahk_class HH Parent

    Gosub, Get_Chm_IE_Path
    File_Path = %pthValue%
  }

  File_Path = %File_Path% ; избавляемся от возможных пробелов в начале строки

  msgbox 1 %Exe_Path%`n2 %File_Path%

Return

Get_Chm_IE_Path:
  ;see COM.ahk Standard Library   by Sean   http://www.autohotkey.com/forum/topic22923.html
  ;from: Capture Text from Read Only List
  COM_AccInit()
  If   pacc :=   COM_AccessibleObjectFromWindow(hWnd)
  {
     Loop, %   COM_AccessibleChildren(pacc, COM_Invoke(pacc,&quot;accChildCount&quot;), varChildren)
     If   paccChild:=NumGet(varChildren,16*A_Index-8)
     ttlName :=COM_Invoke(paccChild,&quot;accName&quot;,0)
     pthValue :=COM_Invoke(paccChild,&quot;accValue&quot;,0)
        , COM_Release(paccChild)
     COM_Release(pacc)
  }
  ;;COM_AccTerm()  ;Error in AHK_L

  If WinActive(&quot;ahk_class OpusApp&quot;) ; Word
  {
    COM_Init()
    Word := COM_GetActiveObject(&quot;Word.Application&quot;)
    ActiveDocument := com_invoke(Word,&quot;ActiveDocument&quot;)
    pthValue := COM_Invoke(ActiveDocument, &quot;Path&quot;) . &quot;\&quot; . COM_Invoke(ActiveDocument, &quot;Name&quot;)
  }
Return


;SEE:: Retrieve AddressBar of Firefox through DDE Message
FF_RetrievePageName() 
   { 
   DllCall(&quot;DdeInitializeW&quot;,&quot;UPtrP&quot;,idInst,&quot;Uint&quot;,0,&quot;Uint&quot;,0,&quot;Uint&quot;,0) 

   ; CP_WINANSI = 1004   CP_WINUNICODE = 1200 
   hServer := DllCall(&quot;DdeCreateStringHandleW&quot;,&quot;UPtr&quot;,idInst,&quot;Str&quot;,&quot;firefox&quot;,&quot;int&quot;,1200) 
   hTopic  := DllCall(&quot;DdeCreateStringHandleW&quot;,&quot;UPtr&quot;,idInst,&quot;Str&quot;,&quot;WWW_GetWindowInfo&quot;,&quot;int&quot;,1200) 
   hItem   := DllCall(&quot;DdeCreateStringHandleW&quot;,&quot;UPtr&quot;,idInst,&quot;Str&quot;,&quot;0xFFFFFFFF&quot;,&quot;int&quot;,1200) 

   hConv := DllCall(&quot;DdeConnect&quot;,&quot;UPtr&quot;,idInst,&quot;UPtr&quot;,hServer,&quot;UPtr&quot;,hTopic,&quot;Uint&quot;,0) 
   ; CF_TEXT = 1      CF_UNICODETEXT = 13 
   hData := DllCall(&quot;DdeClientTransaction&quot;,&quot;Uint&quot;,0,&quot;Uint&quot;,0,&quot;UPtr&quot;,hConv,&quot;UPtr&quot;,hItem,&quot;UInt&quot;,1,&quot;Uint&quot;,0x20B0,&quot;Uint&quot;,10000,&quot;UPtrP&quot;,nResult) 
   sData := DllCall(&quot;DdeAccessData&quot;,&quot;Uint&quot;,hData,&quot;Uint&quot;,0,&quot;str&quot;) 

   DllCall(&quot;DdeFreeStringHandle&quot;,&quot;UPtr&quot;,idInst,&quot;UPtr&quot;,hServer) 
   DllCall(&quot;DdeFreeStringHandle&quot;,&quot;UPtr&quot;,idInst,&quot;UPtr&quot;,hTopic) 
   DllCall(&quot;DdeFreeStringHandle&quot;,&quot;UPtr&quot;,idInst,&quot;UPtr&quot;,hItem) 
   DllCall(&quot;DdeUnaccessData&quot;,&quot;UPtr&quot;,hData) 
   DllCall(&quot;DdeFreeDataHandle&quot;,&quot;UPtr&quot;,hData) 
   DllCall(&quot;DdeDisconnect&quot;,&quot;UPtr&quot;,hConv) 
   DllCall(&quot;DdeUninitialize&quot;,&quot;UPtr&quot;,idInst) 
   result:=StrGet(&amp;sData,&quot;cp0&quot;) 
   return result 
   }
Return


GetCommandLine() {
  WinGet, PID_Target, PID, % &quot;ahk_id &quot; WinExist(&quot;A&quot;)
  ComObjGet(&quot;winmgmts:&quot;).ExecQuery(&quot;Select * from Win32_Process WHERE ProcessId = &quot;
  . PID_Target)._NewEnum.next(x)
  GetCommandLine := % x.CommandLine
  Return %GetCommandLine%
}

GetExecutablePath() {
  WinGet, PID_Target, PID, % &quot;ahk_id &quot; WinExist(&quot;A&quot;)
  ComObjGet(&quot;winmgmts:&quot;).ExecQuery(&quot;Select * from Win32_Process WHERE ProcessId = &quot;
  . PID_Target)._NewEnum.next(x)
  GetExecutablePath := % x.ExecutablePath
  Return %GetExecutablePath%
}

; Определение пути Рабочего стола, окна Проводника, Диалога сохранения
GetDesktopExplorerDialogPath() {
  hWnd := WinExist(&quot;A&quot;)
  WinGetClass wClass, ahk_id %hWnd%
    currentDir := GetWindowsExplorerPath(hWnd)
  IfWinActive, ahk_class Progman
    currentDir := A_DESKTOP

  StringReplace, currentDir, currentDir,`%20,%A_Space%,All
  StringReplace, currentDir, currentDir,`/,\,All

  Return %currentDir%
}

GetWindowsExplorerPath(_hWnd)
{
   For explorerPath In ComObjCreate(&quot;Shell.Application&quot;).Windows
      If (explorerPath.hWnd=_hwnd)
         Return, LTrim(explorerPath.LocationURL, &quot;file:///&quot;)
}




;------------------------------------------------------------------------------
; COM.ahk Standard Library
; by Sean
; http://www.autohotkey.com/forum/topic22923.html
;------------------------------------------------------------------------------

COM_Init(bUn = &quot;&quot;)
{
    Static    h
    Return    (bUn&amp;&amp;!h:=&quot;&quot;)||h==&quot;&quot;&amp;&amp;1==(h:=DllCall(&quot;ole32\OleInitialize&quot;,&quot;Uint&quot;,0))?DllCall(&quot;ole32\OleUninitialize&quot;):0
}

COM_Term()
{
    COM_Init(1)
}

COM_VTable(ppv, idx)
{
    Return    NumGet(NumGet(1*ppv)+4*idx)
}

COM_QueryInterface(ppv, IID = &quot;&quot;)
{
    If    DllCall(NumGet(NumGet(1*ppv:=COM_Unwrap(ppv))), &quot;Uint&quot;, ppv+0, &quot;Uint&quot;, COM_GUID4String(IID,IID ? IID:IID=0 ? &quot;{00000000-0000-0000-C000-000000000046}&quot;:&quot;{00020400-0000-0000-C000-000000000046}&quot;), &quot;UintP&quot;, ppv:=0)=0
    Return    ppv
}

COM_AddRef(ppv)
{
    Return    DllCall(NumGet(NumGet(1*ppv:=COM_Unwrap(ppv))+4), &quot;Uint&quot;, ppv)
}

COM_Release(ppv)
{
    If Not    IsObject(ppv)
    Return    DllCall(NumGet(NumGet(1*ppv)+8), &quot;Uint&quot;, ppv)
    Else
    {
    nRef:=    DllCall(NumGet(NumGet(COM_Unwrap(ppv))+8), &quot;Uint&quot;, COM_Unwrap(ppv)), nRef==0 ? (ppv.prm_:=0):&quot;&quot;
    Return    nRef
    }
}

COM_QueryService(ppv, SID, IID = &quot;&quot;)
{
    If    DllCall(NumGet(NumGet(1*ppv:=COM_Unwrap(ppv))), &quot;Uint&quot;, ppv, &quot;Uint&quot;, COM_GUID4String(IID_IServiceProvider,&quot;{6D5140C1-7436-11CE-8034-00AA006009FA}&quot;), &quot;UintP&quot;, psp)=0
    &amp;&amp;    DllCall(NumGet(NumGet(1*psp)+12), &quot;Uint&quot;, psp, &quot;Uint&quot;, COM_GUID4String(SID,SID), &quot;Uint&quot;, IID ? COM_GUID4String(IID,IID):&amp;SID, &quot;UintP&quot;, ppv:=0)+DllCall(NumGet(NumGet(1*psp)+8), &quot;Uint&quot;, psp)*0=0
    Return    COM_Enwrap(ppv)
}

COM_FindConnectionPoint(pdp, DIID)
{
    DllCall(NumGet(NumGet(1*pdp)+ 0), &quot;Uint&quot;, pdp, &quot;Uint&quot;, COM_GUID4String(IID_IConnectionPointContainer, &quot;{B196B284-BAB4-101A-B69C-00AA00341D07}&quot;), &quot;UintP&quot;, pcc)
    DllCall(NumGet(NumGet(1*pcc)+16), &quot;Uint&quot;, pcc, &quot;Uint&quot;, COM_GUID4String(DIID,DIID), &quot;UintP&quot;, pcp)
    DllCall(NumGet(NumGet(1*pcc)+ 8), &quot;Uint&quot;, pcc)
    Return    pcp
}

COM_GetConnectionInterface(pcp)
{
    VarSetCapacity(DIID,16,0)
    DllCall(NumGet(NumGet(1*pcp)+12), &quot;Uint&quot;, pcp, &quot;Uint&quot;, &amp;DIID)
    Return    COM_String4GUID(&amp;DIID)
}

COM_Advise(pcp, psink)
{
    DllCall(NumGet(NumGet(1*pcp)+20), &quot;Uint&quot;, pcp, &quot;Uint&quot;, psink, &quot;UintP&quot;, nCookie)
    Return    nCookie
}

COM_Unadvise(pcp, nCookie)
{
    Return    DllCall(NumGet(NumGet(1*pcp)+24), &quot;Uint&quot;, pcp, &quot;Uint&quot;, nCookie)
}

COM_Enumerate(penum, ByRef Result, ByRef vt = &quot;&quot;)
{
    VarSetCapacity(varResult,16,0)
    If (0 =    hr:=DllCall(NumGet(NumGet(1*penum:=COM_Unwrap(penum))+12), &quot;Uint&quot;, penum, &quot;Uint&quot;, 1, &quot;Uint&quot;, &amp;varResult, &quot;UintP&quot;, 0))
    Result:=(vt:=NumGet(varResult,0,&quot;Ushort&quot;))=9||vt=13?COM_Enwrap(NumGet(varResult,8),vt):vt=8||vt&lt;0x1000&amp;&amp;COM_VariantChangeType(&amp;varResult,&amp;varResult)=0?StrGet(NumGet(varResult,8)) . COM_VariantClear(&amp;varResult):NumGet(varResult,8)
    Return    hr
}

COM_Invoke(pdsp,name=&quot;&quot;,prm0=&quot;vT_NoNe&quot;,prm1=&quot;vT_NoNe&quot;,prm2=&quot;vT_NoNe&quot;,prm3=&quot;vT_NoNe&quot;,prm4=&quot;vT_NoNe&quot;,prm5=&quot;vT_NoNe&quot;,prm6=&quot;vT_NoNe&quot;,prm7=&quot;vT_NoNe&quot;,prm8=&quot;vT_NoNe&quot;,prm9=&quot;vT_NoNe&quot;)
{
    pdsp :=    COM_Unwrap(pdsp)
    If    name=
    Return    DllCall(NumGet(NumGet(1*pdsp)+8),&quot;Uint&quot;,pdsp)
    If    name contains .
    {
        SubStr(name,1,1)!=&quot;.&quot; ? name.=&quot;.&quot;:name:=SubStr(name,2) . &quot;.&quot;
    Loop,    Parse,    name, .
    {
    If    A_Index=1
    {
        name :=    A_LoopField
        Continue
    }
    Else If    name not contains [,(
        prmn :=    &quot;&quot;
    Else If    InStr(&quot;])&quot;,SubStr(name,0))
    Loop,    Parse,    name, [(,&#039;&quot;)]
    If    A_Index=1
        name :=    A_LoopField
    Else    prmn :=    A_LoopField
    Else
    {
        name .=    &quot;.&quot; . A_LoopField
        Continue
    }
    If    A_LoopField!=
        pdsp:=    COM_Invoke(pdsp,name,prmn!=&quot;&quot; ? prmn:&quot;vT_NoNe&quot;),name:=A_LoopField
    Else    Return    prmn!=&quot;&quot;?COM_Invoke(pdsp,name,prmn,prm0,prm1,prm2,prm3,prm4,prm5,prm6,prm7,prm8):COM_Invoke(pdsp,name,prm0,prm1,prm2,prm3,prm4,prm5,prm6,prm7,prm8,prm9)
    }
    }
    Static    varg,namg,iidn,varResult,sParams
    VarSetCapacity(varResult,64,0),sParams?&quot;&quot;:(sParams:=&quot;0123456789&quot;,VarSetCapacity(varg,160,0),VarSetCapacity(namg,88,0),VarSetCapacity(iidn,16,0)),mParams:=0,nParams:=10,nvk:=3
    Loop,     Parse,    sParams
    If    (prm%A_LoopField%==&quot;vT_NoNe&quot;)
    {
         nParams:=A_Index-1
        Break
    }
    Else If    prm%A_LoopField% is integer
        NumPut(SubStr(prm%A_LoopField%,1,1)=&quot;+&quot;?9:prm%A_LoopField%==&quot;-0&quot;?(prm%A_LoopField%:=0x80020004)*0+10:3,NumPut(prm%A_LoopField%,varg,168-16*A_Index),-12)
    Else If    IsObject(prm%A_LoopField%)
        typ:=prm%A_LoopField%[&quot;typ_&quot;],prm:=prm%A_LoopField%[&quot;prm_&quot;],typ+0==&quot;&quot;?(NumPut(&amp;_nam_%A_LoopField%:=typ,namg,84-4*mParams++),typ:=prm%A_LoopField%[&quot;nam_&quot;]+0==&quot;&quot;?prm+0==&quot;&quot;||InStr(prm,&quot;.&quot;)?8:3:prm%A_LoopField%[&quot;nam_&quot;]):&quot;&quot;,NumPut(typ==8?COM_SysString(prm%A_LoopField%,prm):prm,NumPut(typ,varg,160-16*A_Index),4)
    Else    NumPut(COM_SysString(prm%A_LoopField%,prm%A_LoopField%),NumPut(8,varg,160-16*A_Index),4)
    If    nParams
        SubStr(name,0)=&quot;=&quot;?(name:=SubStr(name,1,-1),nvk:=12,NumPut(-3,namg,4)):&quot;&quot;,NumPut(nvk==12?1:mParams,NumPut(nParams,NumPut(&amp;namg+4,NumPut(&amp;varg+160-16*nParams,varResult,16))))
    Global    COM_HR, COM_LR:=&quot;&quot;
    If    (COM_HR:=DllCall(NumGet(NumGet(1*pdsp)+20),&quot;Uint&quot;,pdsp,&quot;Uint&quot;,&amp;iidn,&quot;Uint&quot;,NumPut(&amp;name,namg,84-4*mParams)-4,&quot;Uint&quot;,1+mParams,&quot;Uint&quot;,1024,&quot;Uint&quot;,&amp;namg,&quot;Uint&quot;))=0&amp;&amp;(COM_HR:=DllCall(NumGet(NumGet(1*pdsp)+24),&quot;Uint&quot;,pdsp,&quot;int&quot;,NumGet(namg),&quot;Uint&quot;,&amp;iidn,&quot;Uint&quot;,1024,&quot;Ushort&quot;,nvk,&quot;Uint&quot;,&amp;varResult+16,&quot;Uint&quot;,&amp;varResult,&quot;Uint&quot;,&amp;varResult+32,&quot;Uint&quot;,0,&quot;Uint&quot;))!=0&amp;&amp;nParams&amp;&amp;nvk&lt;4&amp;&amp;NumPut(-3,namg,4)&amp;&amp;(COM_LR:=DllCall(NumGet(NumGet(1*pdsp)+24),&quot;Uint&quot;,pdsp,&quot;int&quot;,NumGet(namg),&quot;Uint&quot;,&amp;iidn,&quot;Uint&quot;,1024,&quot;Ushort&quot;,12,&quot;Uint&quot;,NumPut(1,varResult,28)-16,&quot;Uint&quot;,0,&quot;Uint&quot;,0,&quot;Uint&quot;,0,&quot;Uint&quot;))=0
        COM_HR:=0
    Global    COM_VT:=NumGet(varResult,0,&quot;Ushort&quot;)
    Return    COM_HR=0?COM_VT&gt;1?COM_VT=9||COM_VT=13?COM_Enwrap(NumGet(varResult,8),COM_VT):COM_VT=8||COM_VT&lt;0x1000&amp;&amp;COM_VariantChangeType(&amp;varResult,&amp;varResult)=0?StrGet(NumGet(varResult,8)) . COM_VariantClear(&amp;varResult):NumGet(varResult,8):&quot;&quot;:COM_Error(COM_HR,COM_LR,&amp;varResult+32,name)
}

COM_InvokeSet(pdsp,name,prm0,prm1=&quot;vT_NoNe&quot;,prm2=&quot;vT_NoNe&quot;,prm3=&quot;vT_NoNe&quot;,prm4=&quot;vT_NoNe&quot;,prm5=&quot;vT_NoNe&quot;,prm6=&quot;vT_NoNe&quot;,prm7=&quot;vT_NoNe&quot;,prm8=&quot;vT_NoNe&quot;,prm9=&quot;vT_NoNe&quot;)
{
    Return    COM_Invoke(pdsp,name &quot;=&quot;,prm0,prm1,prm2,prm3,prm4,prm5,prm6,prm7,prm8,prm9)
}

COM_DispInterface(this, prm1=&quot;&quot;, prm2=&quot;&quot;, prm3=&quot;&quot;, prm4=&quot;&quot;, prm5=&quot;&quot;, prm6=&quot;&quot;, prm7=&quot;&quot;, prm8=&quot;&quot;)
{
    Critical
    If    A_EventInfo = 6
        hr:=DllCall(NumGet(NumGet(0+p:=NumGet(this+8))+28),&quot;Uint&quot;,p,&quot;Uint&quot;,prm1,&quot;UintP&quot;,pname,&quot;Uint&quot;,1,&quot;UintP&quot;,0),hr==0?(sfn:=StrGet(this+40) . StrGet(pname),COM_SysFreeString(pname),%sfn%(prm5,this,prm6)):&quot;&quot;
    Else If    A_EventInfo = 5
        hr:=DllCall(NumGet(NumGet(0+p:=NumGet(this+8))+40),&quot;Uint&quot;,p,&quot;Uint&quot;,prm2,&quot;Uint&quot;,prm3,&quot;Uint&quot;,prm5)
    Else If    A_EventInfo = 4
        NumPut(0*hr:=0x80004001,prm3+0)
    Else If    A_EventInfo = 3
        NumPut(0,prm1+0)
    Else If    A_EventInfo = 2
        NumPut(hr:=NumGet(this+4)-1,this+4)
    Else If    A_EventInfo = 1
        NumPut(hr:=NumGet(this+4)+1,this+4)
    Else If    A_EventInfo = 0
        COM_IsEqualGUID(this+24,prm1)||InStr(&quot;{00020400-0000-0000-C000-000000000046}{00000000-0000-0000-C000-000000000046}&quot;,COM_String4GUID(prm1)) ? NumPut(NumPut(NumGet(this+4)+1,this+4)-8,prm2+0):NumPut(0*hr:=0x80004002,prm2+0)
    Return    hr
}

COM_DispGetParam(pDispParams, Position = 0, vt = 8)
{
    VarSetCapacity(varResult,16,0)
    DllCall(&quot;oleaut32\DispGetParam&quot;, &quot;Uint&quot;, pDispParams, &quot;Uint&quot;, Position, &quot;Ushort&quot;, vt, &quot;Uint&quot;, &amp;varResult, &quot;UintP&quot;, nArgErr)
    Return    (vt:=NumGet(varResult,0,&quot;Ushort&quot;))=8?StrGet(NumGet(varResult,8)) . COM_VariantClear(&amp;varResult):vt=9||vt=13?COM_Enwrap(NumGet(varResult,8),vt):NumGet(varResult,8)
}

COM_DispSetParam(val, pDispParams, Position = 0, vt = 8)
{
    Return    NumPut(vt=8?COM_SysAllocString(val):vt=9||vt=13?COM_Unwrap(val):val,NumGet(NumGet(pDispParams+0)+(NumGet(pDispParams+8)-Position)*16-8),0,vt=11||vt=2 ? &quot;short&quot;:&quot;int&quot;)
}

COM_Error(hr = &quot;&quot;, lr = &quot;&quot;, pei = &quot;&quot;, name = &quot;&quot;)
{
    Static    bDebug:=1
    If Not    pei
    {
    bDebug:=hr
    Global    COM_HR, COM_LR
    Return    COM_HR&amp;&amp;COM_LR ? COM_LR&lt;&lt;32|COM_HR:COM_HR
    }
    Else If    !bDebug
    Return
    hr ? (VarSetCapacity(sError,1022),VarSetCapacity(nError,62),DllCall(&quot;kernel32\FormatMessage&quot;,&quot;Uint&quot;,0x1200,&quot;Uint&quot;,0,&quot;Uint&quot;,hr&lt;&gt;0x80020009?hr:(bExcep:=1)*(hr:=NumGet(pei+28))?hr:hr:=NumGet(pei+0,0,&quot;Ushort&quot;)+0x80040200,&quot;Uint&quot;,0,&quot;str&quot;,sError,&quot;Uint&quot;,512,&quot;Uint&quot;,0),DllCall(&quot;kernel32\FormatMessage&quot;,&quot;Uint&quot;,0x2400,&quot;str&quot;,&quot;0x%1!p!&quot;,&quot;Uint&quot;,0,&quot;Uint&quot;,0,&quot;str&quot;,nError,&quot;Uint&quot;,32,&quot;UintP&quot;,hr)):sError:=&quot;No COM Dispatch Object!`n&quot;,lr?(VarSetCapacity(sError2,1022),VarSetCapacity(nError2,62),DllCall(&quot;kernel32\FormatMessage&quot;,&quot;Uint&quot;,0x1200,&quot;Uint&quot;,0,&quot;Uint&quot;,lr,&quot;Uint&quot;,0,&quot;str&quot;,sError2,&quot;Uint&quot;,512,&quot;Uint&quot;,0),DllCall(&quot;kernel32\FormatMessage&quot;,&quot;Uint&quot;,0x2400,&quot;str&quot;,&quot;0x%1!p!&quot;,&quot;Uint&quot;,0,&quot;Uint&quot;,0,&quot;str&quot;,nError2,&quot;Uint&quot;,32,&quot;UintP&quot;,lr)):&quot;&quot;
    MsgBox, 260, COM Error Notification, % &quot;Function Name:`t&quot;&quot;&quot; . name . &quot;&quot;&quot;`nERROR:`t&quot; . sError . &quot;`t(&quot; . nError . &quot;)&quot; . (bExcep ? SubStr(NumGet(pei+24) ? DllCall(NumGet(pei+24),&quot;Uint&quot;,pei) : &quot;&quot;,1,0) . &quot;`nPROG:`t&quot; . StrGet(NumGet(pei+4)) . COM_SysFreeString(NumGet(pei+4)) . &quot;`nDESC:`t&quot; . StrGet(NumGet(pei+8)) . COM_SysFreeString(NumGet(pei+8)) . &quot;`nHELP:`t&quot; . StrGet(NumGet(pei+12)) . COM_SysFreeString(NumGet(pei+12)) . &quot;,&quot; . NumGet(pei+16) : &quot;&quot;) . (lr ? &quot;`n`nERROR2:`t&quot; . sError2 . &quot;`t(&quot; . nError2 . &quot;)&quot; : &quot;&quot;) . &quot;`n`nWill Continue?&quot;
    IfMsgBox, No, Exit
}

COM_CreateIDispatch()
{
    Static    IDispatch
    If Not    VarSetCapacity(IDispatch)
    {
        VarSetCapacity(IDispatch,28,0),   nParams=3112469
        Loop,   Parse,   nParams
        NumPut(RegisterCallback(&quot;COM_DispInterface&quot;,&quot;&quot;,A_LoopField,A_Index-1),IDispatch,4*(A_Index-1))
    }
    Return &amp;IDispatch
}

COM_GetDefaultInterface(pdisp)
{
    DllCall(NumGet(NumGet(1*pdisp) +12), &quot;Uint&quot;, pdisp , &quot;UintP&quot;, ctinf)
    If    ctinf
    {
    DllCall(NumGet(NumGet(1*pdisp)+16), &quot;Uint&quot;, pdisp, &quot;Uint&quot; , 0, &quot;Uint&quot;, 1024, &quot;UintP&quot;, ptinf)
    DllCall(NumGet(NumGet(1*ptinf)+12), &quot;Uint&quot;, ptinf, &quot;UintP&quot;, pattr)
    DllCall(NumGet(NumGet(1*pdisp)+ 0), &quot;Uint&quot;, pdisp, &quot;Uint&quot; , pattr, &quot;UintP&quot;, ppv)
    DllCall(NumGet(NumGet(1*ptinf)+76), &quot;Uint&quot;, ptinf, &quot;Uint&quot; , pattr)
    DllCall(NumGet(NumGet(1*ptinf)+ 8), &quot;Uint&quot;, ptinf)
    If    ppv
    DllCall(NumGet(NumGet(1*pdisp)+ 8), &quot;Uint&quot;, pdisp),    pdisp := ppv
    }
    Return    pdisp
}

COM_GetDefaultEvents(pdisp)
{
    DllCall(NumGet(NumGet(1*pdisp)+16), &quot;Uint&quot;, pdisp, &quot;Uint&quot; , 0, &quot;Uint&quot;, 1024, &quot;UintP&quot;, ptinf)
    DllCall(NumGet(NumGet(1*ptinf)+12), &quot;Uint&quot;, ptinf, &quot;UintP&quot;, pattr)
    VarSetCapacity(IID,16),DllCall(&quot;kernel32\RtlMoveMemory&quot;,&quot;Uint&quot;,&amp;IID,&quot;Uint&quot;,pattr,&quot;Uint&quot;,16)
    DllCall(NumGet(NumGet(1*ptinf)+76), &quot;Uint&quot;, ptinf, &quot;Uint&quot; , pattr)
    DllCall(NumGet(NumGet(1*ptinf)+72), &quot;Uint&quot;, ptinf, &quot;UintP&quot;, ptlib, &quot;UintP&quot;, idx)
    DllCall(NumGet(NumGet(1*ptinf)+ 8), &quot;Uint&quot;, ptinf)
    Loop, %    DllCall(NumGet(NumGet(1*ptlib)+12), &quot;Uint&quot;, ptlib)
    {
        DllCall(NumGet(NumGet(1*ptlib)+20), &quot;Uint&quot;, ptlib, &quot;Uint&quot;, A_Index-1, &quot;UintP&quot;, TKind)
        If    TKind &lt;&gt; 5
            Continue
        DllCall(NumGet(NumGet(1*ptlib)+16), &quot;Uint&quot;, ptlib, &quot;Uint&quot;, A_Index-1, &quot;UintP&quot;, ptinf)
        DllCall(NumGet(NumGet(1*ptinf)+12), &quot;Uint&quot;, ptinf, &quot;UintP&quot;, pattr)
        nCount:=NumGet(pattr+48,0,&quot;Ushort&quot;)
        DllCall(NumGet(NumGet(1*ptinf)+76), &quot;Uint&quot;, ptinf, &quot;Uint&quot; , pattr)
        Loop, %    nCount
        {
            DllCall(NumGet(NumGet(1*ptinf)+36), &quot;Uint&quot;, ptinf, &quot;Uint&quot;, A_Index-1, &quot;UintP&quot;, nFlags)
            If    !(nFlags &amp; 1)
                Continue
            DllCall(NumGet(NumGet(1*ptinf)+32), &quot;Uint&quot;, ptinf, &quot;Uint&quot;, A_Index-1, &quot;UintP&quot;, hRefType)
            DllCall(NumGet(NumGet(1*ptinf)+56), &quot;Uint&quot;, ptinf, &quot;Uint&quot;, hRefType , &quot;UintP&quot;, prinf)
            DllCall(NumGet(NumGet(1*prinf)+12), &quot;Uint&quot;, prinf, &quot;UintP&quot;, pattr)
            nFlags &amp; 2 ? DIID:=COM_String4GUID(pattr) : bFind:=COM_IsEqualGUID(pattr,&amp;IID)
            DllCall(NumGet(NumGet(1*prinf)+76), &quot;Uint&quot;, prinf, &quot;Uint&quot; , pattr)
            DllCall(NumGet(NumGet(1*prinf)+ 8), &quot;Uint&quot;, prinf)
        }
        DllCall(NumGet(NumGet(1*ptinf)+ 8), &quot;Uint&quot;, ptinf)
        If    bFind
            Break
    }
    DllCall(NumGet(NumGet(1*ptlib)+ 8), &quot;Uint&quot;, ptlib)
    Return    bFind ? DIID : &quot;{00000000-0000-0000-0000-000000000000}&quot;
}

COM_GetGuidOfName(pdisp, Name)
{
    DllCall(NumGet(NumGet(1*pdisp)+16), &quot;Uint&quot;, pdisp, &quot;Uint&quot;, 0, &quot;Uint&quot;, 1024, &quot;UintP&quot;, ptinf)
    DllCall(NumGet(NumGet(1*ptinf)+72), &quot;Uint&quot;, ptinf, &quot;UintP&quot;, ptlib, &quot;UintP&quot;, idx)
    DllCall(NumGet(NumGet(1*ptinf)+ 8), &quot;Uint&quot;, ptinf), ptinf:=0
    DllCall(NumGet(NumGet(1*ptlib)+44), &quot;Uint&quot;, ptlib, &quot;Uint&quot;, &amp;Name, &quot;Uint&quot;, 0, &quot;UintP&quot;, ptinf, &quot;UintP&quot;, memID, &quot;UshortP&quot;, 1)
    DllCall(NumGet(NumGet(1*ptlib)+ 8), &quot;Uint&quot;, ptlib)
    DllCall(NumGet(NumGet(1*ptinf)+12), &quot;Uint&quot;, ptinf, &quot;UintP&quot;, pattr)
    GUID := COM_String4GUID(pattr)
    DllCall(NumGet(NumGet(1*ptinf)+76), &quot;Uint&quot;, ptinf, &quot;Uint&quot; , pattr)
    DllCall(NumGet(NumGet(1*ptinf)+ 8), &quot;Uint&quot;, ptinf)
    Return    GUID
}

COM_GetTypeInfoOfGuid(pdisp, GUID)
{
    DllCall(NumGet(NumGet(1*pdisp)+16), &quot;Uint&quot;, pdisp, &quot;Uint&quot;, 0, &quot;Uint&quot;, 1024, &quot;UintP&quot;, ptinf)
    DllCall(NumGet(NumGet(1*ptinf)+72), &quot;Uint&quot;, ptinf, &quot;UintP&quot;, ptlib, &quot;UintP&quot;, idx)
    DllCall(NumGet(NumGet(1*ptinf)+ 8), &quot;Uint&quot;, ptinf), ptinf := 0
    DllCall(NumGet(NumGet(1*ptlib)+24), &quot;Uint&quot;, ptlib, &quot;Uint&quot;, COM_GUID4String(GUID,GUID), &quot;UintP&quot;, ptinf)
    DllCall(NumGet(NumGet(1*ptlib)+ 8), &quot;Uint&quot;, ptlib)
    Return    ptinf
}

COM_ConnectObject(pdisp, prefix = &quot;&quot;, DIID = &quot;&quot;)
{
    pdisp:=    COM_Unwrap(pdisp)
    If Not    DIID
        0+(pconn:=COM_FindConnectionPoint(pdisp,&quot;{00020400-0000-0000-C000-000000000046}&quot;)) ? (DIID:=COM_GetConnectionInterface(pconn))=&quot;{00020400-0000-0000-C000-000000000046}&quot; ? DIID:=COM_GetDefaultEvents(pdisp):&quot;&quot;:pconn:=COM_FindConnectionPoint(pdisp,DIID:=COM_GetDefaultEvents(pdisp))
    Else    pconn:=COM_FindConnectionPoint(pdisp,SubStr(DIID,1,1)=&quot;{&quot; ? DIID:DIID:=COM_GetGuidOfName(pdisp,DIID))
    If    !pconn||!ptinf:=COM_GetTypeInfoOfGuid(pdisp,DIID)
    {
        MsgBox, No Event Interface Exists!
        Return
    }
    NumPut(pdisp,NumPut(ptinf,NumPut(1,NumPut(COM_CreateIDispatch(),0+psink:=COM_CoTaskMemAlloc(40+nSize:=StrLen(prefix)*2+2)))))
    DllCall(&quot;kernel32\RtlMoveMemory&quot;,&quot;Uint&quot;,psink+24,&quot;Uint&quot;,COM_GUID4String(DIID,DIID),&quot;Uint&quot;,16)
    DllCall(&quot;kernel32\RtlMoveMemory&quot;,&quot;Uint&quot;,psink+40,&quot;Uint&quot;,&amp;prefix,&quot;Uint&quot;,nSize)
    NumPut(COM_Advise(pconn,psink),NumPut(pconn,psink+16))
    Return    psink
}

COM_DisconnectObject(psink)
{
    Return    COM_Unadvise(NumGet(psink+16),NumGet(psink+20))=0 ? (0,COM_Release(NumGet(psink+16)),COM_Release(NumGet(psink+8)),COM_CoTaskMemFree(psink)):1
}

COM_CreateObject(CLSID, IID = &quot;&quot;, CLSCTX = 21)
{
    ppv :=    COM_CreateInstance(CLSID,IID,CLSCTX)
    Return    IID==&quot;&quot; ? COM_Enwrap(ppv):ppv
}

COM_GetObject(Name)
{
    COM_Init()
    If    DllCall(&quot;ole32\CoGetObject&quot;, &quot;Uint&quot;, &amp;Name, &quot;Uint&quot;, 0, &quot;Uint&quot;, COM_GUID4String(IID_IDispatch,&quot;{00020400-0000-0000-C000-000000000046}&quot;), &quot;UintP&quot;, pdisp)=0
    Return    COM_Enwrap(pdisp)
}

COM_GetActiveObject(CLSID)
{
    COM_Init()
    If    DllCall(&quot;oleaut32\GetActiveObject&quot;, &quot;Uint&quot;, COM_GUID4String(CLSID,CLSID), &quot;Uint&quot;, 0, &quot;UintP&quot;, punk)=0
    &amp;&amp;    DllCall(NumGet(NumGet(1*punk)), &quot;Uint&quot;, punk, &quot;Uint&quot;, COM_GUID4String(IID_IDispatch,&quot;{00020400-0000-0000-C000-000000000046}&quot;), &quot;UintP&quot;, pdisp)+DllCall(NumGet(NumGet(1*punk)+8), &quot;Uint&quot;, punk)*0=0
    Return    COM_Enwrap(pdisp)
}

COM_CreateInstance(CLSID, IID = &quot;&quot;, CLSCTX = 21)
{
    COM_Init()
    If    DllCall(&quot;ole32\CoCreateInstance&quot;, &quot;Uint&quot;, COM_GUID4String(CLSID,CLSID), &quot;Uint&quot;, 0, &quot;Uint&quot;, CLSCTX, &quot;Uint&quot;, COM_GUID4String(IID,IID ? IID:IID=0 ? &quot;{00000000-0000-0000-C000-000000000046}&quot;:&quot;{00020400-0000-0000-C000-000000000046}&quot;), &quot;UintP&quot;, ppv)=0
    Return    ppv
}

COM_CLSID4ProgID(ByRef CLSID, ProgID)
{
    VarSetCapacity(CLSID,16,0)
    DllCall(&quot;ole32\CLSIDFromProgID&quot;, &quot;Uint&quot;, &amp;ProgID, &quot;Uint&quot;, &amp;CLSID)
    Return    &amp;CLSID
}

COM_ProgID4CLSID(pCLSID)
{
    DllCall(&quot;ole32\ProgIDFromCLSID&quot;, &quot;Uint&quot;, pCLSID, &quot;UintP&quot;, pProgID)
    Return    StrGet(pProgID) . COM_CoTaskMemFree(pProgID)
}

COM_GUID4String(ByRef CLSID, String)
{
    VarSetCapacity(CLSID,16,0)
    DllCall(&quot;ole32\CLSIDFromString&quot;, &quot;Uint&quot;, &amp;String, &quot;Uint&quot;, &amp;CLSID)
    Return    &amp;CLSID
}

COM_String4GUID(pGUID)
{
    VarSetCapacity(String,38*2)
    DllCall(&quot;ole32\StringFromGUID2&quot;, &quot;Uint&quot;, pGUID, &quot;str&quot;, String, &quot;int&quot;, 39)
    Return    String
}

COM_IsEqualGUID(pGUID1, pGUID2)
{
    Return    DllCall(&quot;ole32\IsEqualGUID&quot;, &quot;Uint&quot;, pGUID1, &quot;Uint&quot;, pGUID2)
}

COM_CoCreateGuid()
{
    VarSetCapacity(GUID,16,0)
    DllCall(&quot;ole32\CoCreateGuid&quot;, &quot;Uint&quot;, &amp;GUID)
    Return    COM_String4GUID(&amp;GUID)
}

COM_CoInitialize()
{
    Return    DllCall(&quot;ole32\CoInitialize&quot;, &quot;Uint&quot;, 0)
}

COM_CoUninitialize()
{
        DllCall(&quot;ole32\CoUninitialize&quot;)
}

COM_CoTaskMemAlloc(cb)
{
    Return    DllCall(&quot;ole32\CoTaskMemAlloc&quot;, &quot;Uint&quot;, cb)
}

COM_CoTaskMemFree(pv)
{
        DllCall(&quot;ole32\CoTaskMemFree&quot;, &quot;Uint&quot;, pv)
}

COM_SysAllocString(str)
{
    Return    DllCall(&quot;oleaut32\SysAllocString&quot;, &quot;Uint&quot;, &amp;str)
}

COM_SysFreeString(pstr)
{
        DllCall(&quot;oleaut32\SysFreeString&quot;, &quot;Uint&quot;, pstr)
}

COM_SafeArrayDestroy(psar)
{
    Return    DllCall(&quot;oleaut32\SafeArrayDestroy&quot;, &quot;Uint&quot;, psar)
}

COM_VariantClear(pvar)
{
        DllCall(&quot;oleaut32\VariantClear&quot;, &quot;Uint&quot;, pvar)
}

COM_VariantChangeType(pvarDst, pvarSrc, vt = 8)
{
    Return    DllCall(&quot;oleaut32\VariantChangeTypeEx&quot;, &quot;Uint&quot;, pvarDst, &quot;Uint&quot;, pvarSrc, &quot;Uint&quot;, 1024, &quot;Ushort&quot;, 0, &quot;Ushort&quot;, vt)
}

COM_SysString(ByRef wString, sString)
{
    VarSetCapacity(wString,4+nLen:=2*StrLen(sString))
    Return    DllCall(&quot;kernel32\lstrcpyW&quot;,&quot;Uint&quot;,NumPut(nLen,wString),&quot;Uint&quot;,&amp;sString)
}

COM_AccInit()
{
    Static    h
    If Not    h
    COM_Init(), h:=DllCall(&quot;kernel32\LoadLibrary&quot;,&quot;str&quot;,&quot;oleacc&quot;)
}

COM_AccTerm()
{
    COM_Term()
}

COM_AccessibleChildren(pacc, cChildren, ByRef varChildren)
{
    VarSetCapacity(varChildren,cChildren*16,0)
    If    DllCall(&quot;oleacc\AccessibleChildren&quot;, &quot;Uint&quot;, COM_Unwrap(pacc), &quot;Uint&quot;, 0, &quot;Uint&quot;, cChildren+0, &quot;Uint&quot;, &amp;varChildren, &quot;UintP&quot;, cChildren:=0)=0
    Return    cChildren
}

COM_AccessibleObjectFromEvent(hWnd, idObject, idChild, ByRef _idChild_=&quot;&quot;)
{
    COM_AccInit(), VarSetCapacity(varChild,16,0)
    If    DllCall(&quot;oleacc\AccessibleObjectFromEvent&quot;, &quot;Uint&quot;, hWnd, &quot;Uint&quot;, idObject, &quot;Uint&quot;, idChild, &quot;UintP&quot;, pacc, &quot;Uint&quot;, &amp;varChild)=0
    Return    COM_Enwrap(pacc), _idChild_:=NumGet(varChild,8)
}

COM_AccessibleObjectFromPoint(x, y, ByRef _idChild_=&quot;&quot;)
{
    COM_AccInit(), VarSetCapacity(varChild,16,0)
    If    DllCall(&quot;oleacc\AccessibleObjectFromPoint&quot;, &quot;int&quot;, x, &quot;int&quot;, y, &quot;UintP&quot;, pacc, &quot;Uint&quot;, &amp;varChild)=0
    Return    COM_Enwrap(pacc), _idChild_:=NumGet(varChild,8)
}

COM_AccessibleObjectFromWindow(hWnd, idObject=-4, IID = &quot;&quot;)
{
    COM_AccInit()
    If    DllCall(&quot;oleacc\AccessibleObjectFromWindow&quot;, &quot;Uint&quot;, hWnd, &quot;Uint&quot;, idObject, &quot;Uint&quot;, COM_GUID4String(IID, IID ? IID : idObject&amp;0xFFFFFFFF==0xFFFFFFF0 ? &quot;{00020400-0000-0000-C000-000000000046}&quot;:&quot;{618736E0-3C3D-11CF-810C-00AA00389B71}&quot;), &quot;UintP&quot;, pacc)=0
    Return    COM_Enwrap(pacc)
}

COM_WindowFromAccessibleObject(pacc)
{
    If    DllCall(&quot;oleacc\WindowFromAccessibleObject&quot;, &quot;Uint&quot;, COM_Unwrap(pacc), &quot;UintP&quot;, hWnd)=0
    Return    hWnd
}

COM_GetRoleText(nRole)
{
    nLen:=    DllCall(&quot;oleacc\GetRoleTextW&quot;, &quot;Uint&quot;, nRole, &quot;Uint&quot;, 0, &quot;Uint&quot;, 0)
    VarSetCapacity(sRole,nLen*2)
    If    DllCall(&quot;oleacc\GetRoleTextW&quot;, &quot;Uint&quot;, nRole, &quot;str&quot;, sRole, &quot;Uint&quot;, nLen+1)
    Return    sRole
}

COM_GetStateText(nState)
{
    nLen:=    DllCall(&quot;oleacc\GetStateTextW&quot;, &quot;Uint&quot;, nState, &quot;Uint&quot;, 0, &quot;Uint&quot;, 0)
    VarSetCapacity(sState,nLen*2)
    If    DllCall(&quot;oleacc\GetStateTextW&quot;, &quot;Uint&quot;, nState, &quot;str&quot;, sState, &quot;Uint&quot;, nLen+1)
    Return    sState
}

COM_AtlAxWinInit(Version = &quot;&quot;)
{
    Static    h
    If Not    h
    COM_Init(), h:=DllCall(&quot;kernel32\LoadLibrary&quot;,&quot;str&quot;,&quot;atl&quot; . Version), DllCall(&quot;atl&quot; . Version . &quot;\AtlAxWinInit&quot;)
}

COM_AtlAxWinTerm(Version = &quot;&quot;)
{
    COM_Term()
}

COM_AtlAxGetHost(hWnd, Version = &quot;&quot;)
{
    If    DllCall(&quot;atl&quot; . Version . &quot;\AtlAxGetHost&quot;, &quot;Uint&quot;, hWnd, &quot;UintP&quot;, punk)=0
    Return    COM_Enwrap(COM_QueryInterface(punk)+COM_Release(punk)*0)
}

COM_AtlAxGetControl(hWnd, Version = &quot;&quot;)
{
    If    DllCall(&quot;atl&quot; . Version . &quot;\AtlAxGetControl&quot;, &quot;Uint&quot;, hWnd, &quot;UintP&quot;, punk)=0
    Return    COM_Enwrap(COM_QueryInterface(punk)+COM_Release(punk)*0)
}

COM_AtlAxAttachControl(pdsp, hWnd, Version = &quot;&quot;)
{
    If    DllCall(&quot;atl&quot; . Version . &quot;\AtlAxAttachControl&quot;, &quot;Uint&quot;, punk:=COM_QueryInterface(pdsp,0), &quot;Uint&quot;, hWnd, &quot;Uint&quot;, COM_AtlAxWinInit(Version))+COM_Release(punk)*0=0
    Return    COM_Enwrap(pdsp)
}

COM_AtlAxCreateControl(hWnd, Name, Version = &quot;&quot;)
{
    If    DllCall(&quot;atl&quot; . Version . &quot;\AtlAxCreateControl&quot;, &quot;Uint&quot;, &amp;Name, &quot;Uint&quot;, hWnd, &quot;Uint&quot;, 0, &quot;Uint&quot;, COM_AtlAxWinInit(Version))=0
    Return    COM_AtlAxGetControl(hWnd,Version)
}

COM_AtlAxCreateContainer(hWnd, l, t, w, h, Name = &quot;&quot;, Version = &quot;&quot;)
{
    Return    DllCall(&quot;user32\CreateWindowEx&quot;, &quot;Uint&quot;,0x200, &quot;str&quot;, &quot;AtlAxWin&quot; . Version, &quot;Uint&quot;, Name?&amp;Name:0, &quot;Uint&quot;, 0x54000000, &quot;int&quot;, l, &quot;int&quot;, t, &quot;int&quot;, w, &quot;int&quot;, h, &quot;Uint&quot;, hWnd, &quot;Uint&quot;, 0, &quot;Uint&quot;, 0, &quot;Uint&quot;, COM_AtlAxWinInit(Version))
}

COM_AtlAxGetContainer(pdsp, bCtrl = &quot;&quot;)
{
    DllCall(NumGet(NumGet(1*pdsp:=COM_Unwrap(pdsp))), &quot;Uint&quot;, pdsp, &quot;Uint&quot;, COM_GUID4String(IID_IOleWindow,&quot;{00000114-0000-0000-C000-000000000046}&quot;), &quot;UintP&quot;, pwin)
    DllCall(NumGet(NumGet(1*pwin)+12), &quot;Uint&quot;, pwin, &quot;UintP&quot;, hCtrl)
    DllCall(NumGet(NumGet(1*pwin)+ 8), &quot;Uint&quot;, pwin)
    Return    bCtrl?hCtrl:DllCall(&quot;user32\GetParent&quot;, &quot;Uint&quot;, hCtrl)
}

COM_ScriptControl(sCode, sEval = &quot;&quot;, sName = &quot;&quot;, Obj = &quot;&quot;, bGlobal = &quot;&quot;)
{
    oSC:=COM_CreateObject(&quot;ScriptControl&quot;), oSC.Language(sEval+0==&quot;&quot;?&quot;VBScript&quot;:&quot;JScript&quot;), sName&amp;&amp;Obj?oSC.AddObject(sName,Obj,bGlobal):&quot;&quot;
    Return    sEval?oSC.Eval(sEval+0?sCode:sEval oSC.AddCode(sCode)):oSC.ExecuteStatement(sCode)
}

COM_Parameter(typ, prm = &quot;&quot;, nam = &quot;&quot;)
{
    Return    IsObject(prm)?prm:Object(&quot;typ_&quot;,typ,&quot;prm_&quot;,prm,&quot;nam_&quot;,nam)
}

COM_Enwrap(obj, vt = 9)
{
    Static    base
    Return    IsObject(obj)?obj:Object(&quot;prm_&quot;,obj,&quot;typ_&quot;,vt,&quot;base&quot;,base?base:base:=Object(&quot;__Delete&quot;,&quot;COM_Invoke&quot;,&quot;__Call&quot;,&quot;COM_Invoke&quot;,&quot;__Get&quot;,&quot;COM_Invoke&quot;,&quot;__Set&quot;,&quot;COM_InvokeSet&quot;,&quot;base&quot;,Object(&quot;__Delete&quot;,&quot;COM_Term&quot;)))
}

COM_Unwrap(obj)
{
    Return    IsObject(obj)?obj.prm_:obj
}
;------------------------------------------------------------------------------
; END  COM.ahk Standard Library
;------------------------------------------------------------------------------</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (DD)]]></author>
			<pubDate>Fri, 25 Nov 2011 22:15:36 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=53863#p53863</guid>
		</item>
	</channel>
</rss>
