Thanks Helgef, A_LastError is a good suggestion but it didn't appear to work.
I've tried adding/removing a tab, and getting the window style/ExStyle before/after, (see the code,) but it didn't show any difference.
I've posted my code, in case I've missed something:
Code: Select all
;useful example at the bottom of:
;DllCall
;https://autohotkey.com/docs/commands/DllCall.htm
;it appears that the return value is always 0, so we don't have info re. identifying which windows have a taskbar button
q:: ;try to set taskbar value, if it fails then check for an error message that would indicate that the window doesn't have a taskbar button
IID_ITaskbarList := "{56FDF342-FD6D-11d0-958A-006097C9A090}"
IID_ITaskbarList3 := "{EA1AFB91-9E28-4B86-90E9-9E9F8A5EEFAF}"
CLSID_TaskbarList := "{56FDF344-FD6D-11d0-958A-006097C9A090}"
;itbl := ComObjCreate(CLSID_TaskbarList, IID_ITaskbarList)
itbl := ComObjCreate(CLSID_TaskbarList, IID_ITaskbarList3)
DetectHiddenWindows, Off
WinGet, vWinList, List
DetectHiddenWindows, On
DllCall(vtable(itbl,3), Ptr,itbl) ;HrInit
Loop, % vWinList
{
hWnd := vWinList%A_Index%
WinGetTitle, vWinTitle, % "ahk_id " hWnd
if (vWinTitle = "Untitled - Notepad")
{
WinGet, vWinStyle1, Style, % "ahk_id " hWnd
WinGet, vWinExStyle1, ExStyle, % "ahk_id " hWnd
DllCall(vtable(itbl,5), Ptr,itbl, Ptr,hWnd) ;DeleteTab
WinGet, vWinStyle2, Style, % "ahk_id " hWnd
WinGet, vWinExStyle2, ExStyle, % "ahk_id " hWnd
DllCall(vtable(itbl,4), Ptr,itbl, Ptr,hWnd) ;AddTab
WinGet, vWinStyle3, Style, % "ahk_id " hWnd
WinGet, vWinExStyle3, ExStyle, % "ahk_id " hWnd
MsgBox, % vWinStyle1 " " vWinExStyle1 "`r`n" vWinStyle2 " " vWinExStyle2 "`r`n" vWinStyle3 " " vWinExStyle3
}
DllCall("kernel32\SetLastError", UInt,12345) ;12345 is a 'random' number
vRet := DllCall(vtable(itbl,9), Ptr,itbl, Ptr,hWnd, Int64,100, Int64,100) ;SetProgressValue
;vRet := DllCall(vtable(itbl,10), Ptr,itbl, Ptr,hWnd, UInt,0) ;SetProgressState
;vRet := DllCall(vtable(itbl,5), Ptr,itbl, Ptr,hWnd) ;DeleteTab ;removes taskbar buttons but not alt+tab icons
;vRet := DllCall(vtable(itbl,6), Ptr,itbl, Ptr,hWnd) ;ActivateTab
;vRet := DllCall(vtable(itbl,7), Ptr,itbl, Ptr,hWnd) ;SetActiveAlt
vLastError := A_LastError
vOutput .= hWnd "|" vRet "|" vLastError "|" vWinTitle "`r`n"
}
Clipboard := vOutput
MsgBox, % "done"
ObjRelease(itbl)
return
;==================================================
vtable(ptr, n) {
; 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), n*A_PtrSize)
}
;==================================================
[EDIT:] Btw I was curious as to whether some of the techniques in the script could be used to invoke (open) a specific Internet Explorer tab (or list the tabs, although listing the tabs can be done via COM).