Я так понял, что "oleacc\AccessibleChildren" загружает в память сразу все объекты, и после, их жизненно необходимо все перебрать, чтобы для каждого применить "ObjRelease".
И тут уже заявленный в 4 посте прирост скорости (20-25%) стремится к нулю, потому код ниже отличается от 2 поста, только отсутствием привязки к библиотеке.
#SingleInstance Force
#NoEnv
OnExit Exit
hShellTray := WinExist("ahk_class Shell_TrayWnd ahk_exe explorer.exe")
ControlGet, hTaskbar, HWND,, MSTaskListWClass1, ahk_id %hShellTray%
ControlGet, hNotifyWnd, HWND,, TrayNotifyWnd1, ahk_id %hShellTray%
DllCall("LoadLibrary", "Str", "oleacc", "Ptr")
ComObjError(false)
SetTimer, Reload, 1800000
Loop {
Sleep 50
If ((Acc := Acc_NeedChildren(Acc_ObjectFromWindow(hTaskbar),4)) = "")
Continue
Acc.accLocation(ComObj(0x4003,&x:=0), 0, ComObj(0x4003,&w:=0), 0, Acc.accChildCount)
Right := NumGet(x,0,"int") + NumGet(w,0,"int")
ControlGetPos, Left, , , , , ahk_id %hNotifyWnd%
If (prLeft = Left && prRight = Right)
Continue
prLeft := Left, prRight := Right
WinGetPos, wX, , wW, wH, ahk_id %hShellTray%
Right -= wX
WinSet, Region, % Right "-0 0-0 0-" wH " " Right "-" wH " " Right "-0 "
. Left "-" wH " " wW "-" wH " " wW "-0 " Left "-0" " " Left "-" wH
, ahk_id %hShellTray%
}
Reload:
Reload
Esc::
Exit:
WinSet, Region, , ahk_id %hShellTray%
ExitApp
Acc_NeedChildren(Acc, Index) {
cChildren:=Acc.accChildCount, Children:=[]
if DllCall("oleacc\AccessibleChildren", "Ptr",ComObjValue(Acc), "Int",0, "Int",cChildren, "Ptr",VarSetCapacity(varChildren,cChildren*(8+2*A_PtrSize),0)*0+&varChildren, "Int*",cChildren)=0 {
Loop %cChildren%
i:=(A_Index-1)*(A_PtrSize*2+8)+8, child:=NumGet(varChildren,i), Children.Insert(NumGet(varChildren,i-8)=9 ? ComObj(9,ComObjQuery(child, "{618736e0-3c3d-11cf-810c-00aa00389b71}"), 1) : child), NumGet(varChildren,i-8)=9 ? ObjRelease(child) : 0
return Children.MaxIndex() ? Children[Index] : 0
}
}
Acc_ObjectFromWindow(hWnd, idObject = 0) {
If DllCall("oleacc\AccessibleObjectFromWindow", "Ptr", hWnd, "UInt", idObject&=0xFFFFFFFF, "Ptr", -VarSetCapacity(IID,16)+NumPut(idObject==0xFFFFFFF0?0x46000000000000C0:0x719B3800AA000C81,NumPut(idObject==0xFFFFFFF0?0x0000000000020400:0x11CF3C3D618736E0,IID,"Int64"),"Int64"), "Ptr*", pacc) = 0
Return ComObjEnwrap(9, pacc, 1)
}