I tried updating a script from the showcase, but the function now tries to return a ComObject.
Code: Select all
toggle := 1
; Methods in ITaskbarList's VTable:
; IUnknown:
; 0 QueryInterface -- use ComObjQuery() instead
; 1 AddRef -- use ObjAddRef() instead
; 2 Release -- use ObjRelease() instead
; ITaskbarList:
; 3 HrInit
; 4 AddTab
; 5 DeleteTab
; 6 ActivateTab
; 7 SetActiveAlt
F1:: {
global
IID_ITaskbarList := "{56FDF342-FD6D-11d0-958A-006097C9A090}"
CLSID_TaskbarList := "{56FDF344-FD6D-11d0-958A-006097C9A090}"
; Create the TaskbarList object and store its address in tbl.
tbl := ComObject(CLSID_TaskbarList, IID_ITaskbarList)
toggle := !toggle
if (!toggle) {
activeHwnd := WinExist("A")
DllCall(vtable(tbl,3), "ptr", tbl) ; tbl.HrInit()
DllCall(vtable(tbl,5), "ptr", tbl, "ptr", activeHwnd) ; tbl.DeleteTab(activeHwnd)
} else {
DllCall(vtable(tbl,4), "ptr", tbl, "ptr", activeHwnd) ; tbl.AddTab(activeHwnd)
}
; Non-dispatch objects must always be manually freed.
ObjRelease(tbl)
}
vtable(ptr, n) {
global
; NumGet(ptr+0) returns the address of the object's virtual function
; table (vtable for short). The remainder of the expression retrieves
; the address of the nth function's address from the vtable.
return NumGet(NumGet(ptr+0, "UPtr"), n*A_PtrSize, "UPtr")
}
return