Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 08/31/2024 in all areas

  1. Thanks mate, I didn't know you could do that with the line numbers in scite, that's quite handy - The output is also the same as what I see on my end. For anyone following along, I threw a it more time at this today and made a bit more progress. I think that I may have managed to populate a collection of displaymonitor objects. Gotta say that the Rust doco has been invaluable for deciphering those vtables. #AutoIt3Wrapper_UseX64=Y #Tidy_Parameters=/sf #include <winapi.au3> #include <array.au3> ; Com error code reference: ; https://learn.microsoft.com/en-us/windows/win32/com/com-error-codes-1 Global $hDLLComBase = DllOpen("Combase.dll") Global Const $PTR_LEN = @AutoItX64 ? 8 : 4 Global Const $sIUnknown = "{00000000-0000-0000-C000-000000000046}" Global Const $sIInspectable = "{AF86E2E0-B12D-4c6a-9C5A-D7AA65101E90}" Global Const $sIActivationFactory = "{00000035-0000-0000-C000-000000000046}" Global Const $sIDisplayMonitorStatics = "{6EAE698F-A228-4C05-821D-B695D667DE8E}" Global Const $sIDeviceInformationStatics = "{C17F100E-3A46-4A78-8013-769DC9B97390}" Global Const $sIAsyncInfo = "{00000036-0000-0000-C000-000000000046}" Global Enum $ASync_Started = 0, $ASync_Completed, $ASync_Canceled, $ASync_Error ConsoleWrite("Get AQS String" & @CRLF) ConsoleWrite('Get "Windows.Devices.Display.DisplayMonitor" Activation Factory, IDisplayMonitorStatics' & @CRLF) $pMonStatics = RoGetActivationFactory("Windows.Devices.Display.DisplayMonitor", $sIDisplayMonitorStatics) DispError() ConsoleWrite("Call IDisplayMonitorStatics::GetDeviceSelector" & @CRLF) $sDevSelector = IDisplayMonitorStatics_GetDeviceSelector($pMonStatics) DispError() ConsoleWrite($sDevSelector & @CRLF) ConsoleWrite(@CRLF) ConsoleWrite("Get Device Collection:" & @CRLF) ConsoleWrite('Get "Windows.Devices.Enumeration.DeviceInformation" Activation Factory, IDeviceInformationStatics' & @CRLF) $pDevInfo = RoGetActivationFactory("Windows.Devices.Enumeration.DeviceInformation", $sIDeviceInformationStatics) DispError() ConsoleWrite("Call IDeviceInformationStatics::FindAllAsyncAqsFilter with AQS string that we aquired earlier" & @CRLF) $pAsync = IDeviceInformationStatics_FindAllAsyncAqsFilter($pDevInfo, $sDevSelector) DispError() ConsoleWrite("Wait for ASync routine..." & @CRLF) ConsoleWrite("Get AsyncInfo Interface:" & @CRLF) $pAsyncInfo = IUnknown_QueryInterface($pAsync, $sIAsyncInfo) DispError() Do Sleep(10) Until IASyncInfo_Status($pAsyncInfo) ConsoleWrite("Async Finished. We want the status to be 1 - i.e. 'completed':" & @CRLF) ConsoleWrite("Async status=" & IASyncInfo_Status($pAsyncInfo) & @CRLF) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Func CoTaskMemFree($pBlock) DllCall("ole32.dll", "none", "CoTaskMemFree", "ptr", $pBlock) EndFunc ;==>CoTaskMemFree Func CreateGUID($sGUID) Local $tGUID = DllStructCreate($tagGUID) $aGUID = StringSplit(StringRegExpReplace($sGUID, "[{}]", ""), "-", 2) If UBound($aGUID) <> 5 Then Return False $tGUID.Data1 = Dec($aGUID[0]) $tGUID.Data2 = Dec($aGUID[1]) $tGUID.Data3 = Dec($aGUID[2]) $tGUID.Data4 = Binary("0x" & $aGUID[3] & $aGUID[4]) Return $tGUID EndFunc ;==>CreateGUID Func CreateHString($sString) Local $aRes = DllCall($hDLLComBase, "int", "WindowsCreateString", "wstr", $sString, "uint", StringLen($sString), "ptr*", 0) If Not @error Then Return $aRes[3] EndFunc ;==>CreateHString Func DeleteHString(ByRef $hString) Local $aRes = DllCall($hDLLComBase, "int", "WindowsDeleteString", "ptr", $hString) If Not @error Then $hString = 0 EndFunc ;==>DeleteHString Func DispError($iError = @error, $iScriptLineNumber = @ScriptLineNumber) Local Const $iMaxWidth = 0xFF Local $iFlags = $FORMAT_MESSAGE_FROM_SYSTEM Local $tBuff = DllStructCreate(StringFormat("wchar[%d]", $iMaxWidth)) Local $pBuff = DllStructGetPtr($tBuff) Local $iCount = _WinAPI_FormatMessage($iFlags, 0, $iError, 0, $pBuff, $iMaxWidth, 0) ConsoleWrite('(' & $iScriptLineNumber & ",0) [0x" & Hex($iError) & "] " & StringStripWS(DllStructGetData($tBuff, 1), 3) & @CRLF) EndFunc ;==>DispError Func GetPtrAt($pPtr) Local $tPtr = DllStructCreate("ptr ptr", $pPtr) Return $tPtr.ptr EndFunc ;==>GetPtrAt Func IActivationFactory_ActivateInstance($pThis) Local $pVTable = GetPtrAt($pThis) Local $pFunc = GetPtrAt(Ptr($pVTable + 6 * $PTR_LEN)) Local $aRet = DllCallAddress("long", $pFunc, "ptr", $pThis, "ptr*", 0) Return SetError($aRet[0], 0, $aRet[2]) EndFunc ;==>IActivationFactory_ActivateInstance Func IASyncInfo_Cancel($pThis) Local $pVTable = GetPtrAt($pThis) Local $pFunc = GetPtrAt(Ptr($pVTable + 9 * $PTR_LEN)) Local $aRet = DllCallAddress("long", $pFunc, "ptr", $pThis) Return SetError($aRet[0]) EndFunc ;==>IASyncInfo_Cancel Func IASyncInfo_Close($pThis) Local $pVTable = GetPtrAt($pThis) Local $pFunc = GetPtrAt(Ptr($pVTable + 10 * $PTR_LEN)) Local $aRet = DllCallAddress("long", $pFunc, "ptr", $pThis) Return SetError($aRet[0]) EndFunc ;==>IASyncInfo_Close Func IASyncInfo_ErrorCode($pThis) Local $pVTable = GetPtrAt($pThis) Local $pFunc = GetPtrAt(Ptr($pVTable + 8 * $PTR_LEN)) Local $aRet = DllCallAddress("long", $pFunc, "ptr", $pThis, "long*", 0) Return SetError($aRet[0], 0, $aRet[2]) EndFunc ;==>IASyncInfo_ErrorCode Func IASyncInfo_ID($pThis) Local $pVTable = GetPtrAt($pThis) Local $pFunc = GetPtrAt(Ptr($pVTable + 6 * $PTR_LEN)) Local $aRet = DllCallAddress("long", $pFunc, "ptr", $pThis, "uint*", 0) Return SetError($aRet[0], 0, $aRet[2]) EndFunc ;==>IASyncInfo_ID Func IASyncInfo_Status($pThis) Local $pVTable = GetPtrAt($pThis) Local $pFunc = GetPtrAt(Ptr($pVTable + 7 * $PTR_LEN)) Local $aRet = DllCallAddress("long", $pFunc, "ptr", $pThis, "uint*", 0) Return SetError($aRet[0], 0, $aRet[2]) EndFunc ;==>IASyncInfo_Status Func IDeviceInformationStatics_FindAllAsyncAqsFilter($pThis, $sFilter) Local $pVTable = GetPtrAt($pThis) Local $pFunc = GetPtrAt(Ptr($pVTable + 10 * $PTR_LEN)) Local $hsFilter = CreateHString($sFilter) Local $aRet = DllCallAddress("long", $pFunc, "ptr", $pThis, "ptr", $hsFilter, "ptr*", 0) DeleteHString($hsFilter) Return SetError($aRet[0], 0, $aRet[3]) EndFunc ;==>IDeviceInformationStatics_FindAllAsyncAqsFilter Func IDisplayMonitorStatics_FromIdAsync($pThis) Local $pVTable = GetPtrAt($pThis) Local $pFunc = GetPtrAt(Ptr($pVTable + 7 * $PTR_LEN)) Local $aRet = DllCallAddress("long", $pFunc, "ptr", $pThis, "ptr*", 0, "ptr*", 0) Local $sSelector = ReadHString($aRet[2]) DeleteHString($aRet[2]) Return SetError($aRet[0], 0, $sSelector) EndFunc ;==>IDisplayMonitorStatics_FromIdAsync Func IDisplayMonitorStatics_GetDeviceSelector($pThis) Local $pVTable = GetPtrAt($pThis) Local $pFunc = GetPtrAt(Ptr($pVTable + 6 * $PTR_LEN)) Local $aRet = DllCallAddress("long", $pFunc, "ptr", $pThis, "ptr*", 0) Local $sSelector = ReadHString($aRet[2]) DeleteHString($aRet[2]) Return SetError($aRet[0], 0, $sSelector) EndFunc ;==>IDisplayMonitorStatics_GetDeviceSelector Func IInspectable_GetIids($pThis) Local $pVTable = GetPtrAt($pThis) Local $pFunc = GetPtrAt(Ptr($pVTable + 3 * $PTR_LEN)) Local $aRet = DllCallAddress("long", $pFunc, "ptr", $pThis, "long*", 0, "ptr*", 0) Local $iCount = $aRet[2], $asIIDs[$iCount] For $i = 0 To $iCount - 1 $asIIDs[$i] = ReadGUIDAt(Ptr($aRet[3] + ($i * 16))) Next CoTaskMemFree($aRet[3]) Return SetError($aRet[0], 0, $asIIDs) EndFunc ;==>IInspectable_GetIids Func IInspectable_GetRuntimeClassName($pThis) Local $pVTable = GetPtrAt($pThis) Local $pFunc = GetPtrAt(Ptr($pVTable + 4 * $PTR_LEN)) Local $aRet = DllCallAddress("long", $pFunc, "ptr", $pThis, "handle*", 0) Local $sClassName = ReadHString($aRet[2]) DeleteHString($aRet[2]) Return SetError($aRet[0], 0, $sClassName) EndFunc ;==>IInspectable_GetRuntimeClassName Func IInspectable_GetTrustLevel($pThis) Local $pVTable = GetPtrAt($pThis) Local $pFunc = GetPtrAt(Ptr($pVTable + 5 * $PTR_LEN)) Local $aRet = DllCallAddress("long", $pFunc, "ptr", $pThis, "int*", 0) Return SetError($aRet[0], 0, $aRet[2]) EndFunc ;==>IInspectable_GetTrustLevel Func IUnknown_AddRef($pThis) Local $pVTable = GetPtrAt($pThis) Local $pFunc = GetPtrAt(Ptr($pVTable + $PTR_LEN)) Local $aRet = DllCallAddress("long", $pFunc, "ptr", $pThis) Return $aRet[0] EndFunc ;==>IUnknown_AddRef Func IUnknown_QueryInterface($pThis, $sIID) Local $pVTable = GetPtrAt($pThis) Local $pFunc = GetPtrAt($pVTable) Local $tIID = CreateGUID($sIID) Local $aRet = DllCallAddress("long", $pFunc, "ptr", $pThis, "struct*", $tIID, "ptr*", 0) Return SetError($aRet[0], 0, $aRet[3]) EndFunc ;==>IUnknown_QueryInterface Func IUnknown_RemoveRef($pThis) Local $pVTable = GetPtrAt($pThis) Local $pFunc = GetPtrAt(Ptr($pVTable + 2 * $PTR_LEN)) Local $aRet = DllCallAddress("long", $pFunc, "ptr", $pThis) Return $aRet[0] EndFunc ;==>IUnknown_RemoveRef Func ReadGUIDAt($pGUID) Local $tGUID = DllStructCreate($tagGUID, $pGUID) Local $sGUID = "{" $sGUID &= Hex($tGUID.Data1, 8) & "-" $sGUID &= Hex($tGUID.Data2, 4) & "-" $sGUID &= Hex($tGUID.Data3, 4) & "-" $sGUID &= StringMid($tGUID.Data4, 3, 4) & "-" $sGUID &= StringMid($tGUID.Data4, 7, 12) & "}" Return $sGUID EndFunc ;==>ReadGUIDAt Func ReadHString(ByRef $hString) Local $aRes = DllCall($hDLLComBase, "wstr", "WindowsGetStringRawBuffer", "ptr", $hString, "int*", 0) If Not @error Then Return $aRes[0] EndFunc ;==>ReadHString Func RoActivateInstance($sClassID) $hsClassID = CreateHString($sClassID) Local $aRes = DllCall($hDLLComBase, "long", "RoActivateInstance", "handle", $hsClassID, "ptr*", 0) DeleteHString($hsClassID) Return SetError($aRes[0], 0, $aRes[2]) EndFunc ;==>RoActivateInstance Func RoGetActivationFactory($sClassID, $sIID) Local $hsClassID = CreateHString($sClassID) Local $tIID = CreateGUID($sIID) Local $aRes = DllCall($hDLLComBase, "long", "RoGetActivationFactory", "handle", $hsClassID, "ptr", DllStructGetPtr($tIID), "ptr*", 0) DeleteHString($hsClassID) Return SetError($aRes[0], 0, $aRes[3]) EndFunc ;==>RoGetActivationFactory
    2 points
  2. ioa747

    ITaskbarList4 interface

    Here is an attempt to approximate the ITaskbarList3 interface, which was quite a headache for me, since all C++ is new to me https://github.com/MicrosoftDocs/win32/blob/docs/desktop-src/shell/taskbar-extensions.md https://learn.microsoft.com/en-us/windows/win32/api/shobjidl_core/nn-shobjidl_core-itaskbarlist3 The code may have omissions or excesses, as for the writing where I was stuck and did not understand asking the AI So if someone more experienced has any tips, I'd be happy to hear them everything takes place in the taskbar thumbnail, is displayed when the mouse pointer get over the taskbar icon I put it as a UDF in a separate file so that the main script is cleaner Example.au3 ; https://www.autoitscript.com/forum/topic/212223-itaskbarlist4-interface/?do=edit ;---------------------------------------------------------------------------------------- ; Title...........: Example.au3 ; Description.....: Example howto use ITaskbarList3 interface ; AutoIt Version..: 3.3.16.1 Author: ioa747 Script Version: 0.0.0.3 ; Note............: Testet in Win10 22H2 ;---------------------------------------------------------------------------------------- #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include "TaskbarList.au3" ; * <-- Global $bRedyflag = False ; Register to receive the message that our button is ready GUIRegisterMsg(_WinAPI_RegisterWindowMessage("TaskbarButtonCreated"), "_TaskbarReady") ; Create a sample GUI window Global $hGUI = GUICreate("ITaskbarList Example", 330, 200) Global $idIcon = GUICtrlCreateIcon(@ScriptDir & "\Res\imageres-81.ico", -1, 200, 5, 128, 128) Global $idButton = GUICtrlCreateButton("Click Me", 10, 10) Global $ImageList1 = _GUIImageList_Create(32, 32, 5) _GUIImageList_AddIcon($ImageList1, @ScriptDir & "\Res\prev.ico", 0, True) _GUIImageList_AddIcon($ImageList1, @ScriptDir & "\Res\play.ico", 0, True) _GUIImageList_AddIcon($ImageList1, @ScriptDir & "\Res\stop.ico", 0, True) _GUIImageList_AddIcon($ImageList1, @ScriptDir & "\Res\next.ico", 0, True) GUISetState(@SW_SHOW, $hGUI) Global Enum $iTBtnPrev = 1000, $iTBtnPlay, $iTBtnStop, $iTBtnNext ; Register a handler for WM_COMMAND messages GUIRegisterMsg($WM_COMMAND, "_OnThumbnailButtonClick") ; Add a button to the taskbar thumbnail toolbar ; dwMask, iId, iBitmap, hIcon, szTip, dwFlags Global $dwMask = BitOR($THB_BITMAP, $THB_TOOLTIP, $THB_FLAGS) Global $aTButtons[4][6] = [ _ [$dwMask, $iTBtnPrev, 0, 0, "prev", 0], _ [$dwMask, $iTBtnPlay, 1, 0, "play", 0], _ [$dwMask, $iTBtnStop, 2, 0, "stop", 0], _ [$dwMask, $iTBtnNext, 3, 0, "next", 0]] While Not $bRedyflag Sleep(10) WEnd TB_ThumbBarSetImageList($hGUI, $ImageList1) TB_ThumbBarAddButtons($hGUI, 4, $aTButtons) ; Selects a portion of a window's client area to display as that window's thumbnail in the taskbar. TB_SetThumbnailClip($hGUI, 200, 0, 200 + 128, 128) ; Specifies or updates the text of the tooltip that is displayed when the mouse pointer rests on an individual preview thumbnail in a taskbar button flyout. Local $sTxt = "" $sTxt &= " Title...........: Example.au3" & @CRLF $sTxt &= " Description.....: Example howto use ITaskbarList3 " & @CRLF $sTxt &= " AutoIt Version..: 3.3.16.1 Script Version: 1.0" TB_SetThumbnailTooltip($hGUI, $sTxt) Global $hIcon Global $iCnt = 0 While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $idButton ; Applies an overlay to a taskbar button to indicate application status or a notification to the user. $iCnt += 1 ConsoleWrite("$iCnt=" & $iCnt & @CRLF) $hIcon = TB_GetIconHandle($iCnt > 10 ? @ScriptDir & "\Res\trffc14.ico" : @ScriptDir & "\Res\" & $iCnt & ".ico") TB_SetOverlayIcon($hGUI, $hIcon, String($iCnt)) EndSwitch WEnd GUIDelete($hGUI) ;-------------------------------------------------------------------------------------------------------------------------------- ; Function to handle the taskbar ready event Func _TaskbarReady($hWnd, $msg, $wParam, $lParam) Switch $hWnd Case $hGUI ; The taskbar button is ready ConsoleWrite("--- Taskbar button ready ---" & @CRLF) $bRedyflag = True EndSwitch EndFunc ;==>_TaskbarReady ;-------------------------------------------------------------------------------------------------------------------------------- ; Function to handle thumbnail button clicks Func _OnThumbnailButtonClick($hWnd, $msg, $wParam, $lParam) ; Extract the button ID from the wParam Local $iButtonID = BitAND($wParam, 0xFFFF) Switch $iButtonID Case 1000 ; progress status in Thumbnail icon ConsoleWrite("- progress status in Thumbnail icon Button Clicked: " & $iButtonID & @CRLF) ; Load an icon $hIcon = TB_GetIconHandle(@ScriptDir & "\Res\comres-15.ico") TB_SetOverlayIcon($hGUI, $hIcon, "Wait") For $i = 1 To 100 TB_SetProgress($hGUI, $i, 100) Sleep(25) Next TB_Flash($hGUI, 4, 300) $hIcon = TB_GetIconHandle($iCnt > 10 ? @ScriptDir & "\Res\trffc14.ico" : @ScriptDir & "\Res\" & $iCnt & ".ico") TB_SetOverlayIcon($hGUI, $hIcon, String($iCnt)) Case 1001 ; Flash the taskbar icon RED ConsoleWrite("- Flash the taskbar icon RED Button Clicked: " & $iButtonID & @CRLF) For $i = 1 To 4 TB_SetProgressState($hGUI, 4) Sleep(300) TB_SetProgressState($hGUI, 0) Sleep(300) Next TB_SetProgressState($hGUI, 0) Sleep(1000) For $i = 1 To 4 TB_SetProgressState($hGUI, 4) TB_SetProgress($hGUI, 100, 100) Sleep(300) TB_SetProgressState($hGUI, 0) TB_SetProgress($hGUI, 0, 100) Sleep(300) Next TB_SetProgressState($hGUI, 0) Case 1002 ; Flash the taskbar icon YELLOW ConsoleWrite("- Flash the taskbar icon YELLOW Button Clicked: " & $iButtonID & @CRLF) For $i = 1 To 4 TB_SetProgressState($hGUI, 8) Sleep(300) TB_SetProgressState($hGUI, 0) Sleep(300) Next TB_SetProgressState($hGUI, 0) Sleep(1000) For $i = 1 To 4 TB_SetProgressState($hGUI, 8) TB_SetProgress($hGUI, 100, 100) Sleep(300) TB_SetProgressState($hGUI, 0) TB_SetProgress($hGUI, 0, 100) Sleep(300) Next TB_SetProgressState($hGUI, 0) Case 1003 ; progress status in Thumbnail icon ConsoleWrite("- progress status in Thumbnail icon Button Clicked: " & $iButtonID & @CRLF) ; Load an icon $hIcon = TB_GetIconHandle(@ScriptDir & "\Res\comres-15.ico") TB_SetOverlayIcon($hGUI, $hIcon, "Wait") For $i = 1 To 100 Switch $i Case 60 To 84 TB_SetProgressState($hGUI, 8) ;YELLOW Case 85 To 100 TB_SetProgressState($hGUI, 4) ;RED EndSwitch TB_SetProgress($hGUI, $i, 100) Sleep(25) Next TB_Flash($hGUI, 4, 300) TB_SetProgressState($hGUI, 0) $hIcon = TB_GetIconHandle($iCnt > 10 ? @ScriptDir & "\Res\trffc14.ico" : @ScriptDir & "\Res\" & $iCnt & ".ico") TB_SetOverlayIcon($hGUI, $hIcon, String($iCnt)) EndSwitch EndFunc ;==>_OnThumbnailButtonClick TaskbarList.au3 #include-once #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Res_Description=ITaskbarList4 interface #AutoIt3Wrapper_Res_Fileversion=0.0.0.3 #AutoIt3Wrapper_Res_ProductName=TaskbarList.au3 #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** ; https://www.autoitscript.com/forum/topic/212223-itaskbarlist4-interface ; https://github.com/MicrosoftDocs/win32/blob/docs/desktop-src/shell/taskbar-extensions.md ; https://learn.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-itaskbarlist3-registertab ; https://www.autoitscript.com/forum/topic/139260-autoit-snippets/?do=findComment&comment=1536397 ; Images must be 32-bit and of dimensions GetSystemMetrics(SM_CXICON) x GetSystemMetrics(SM_CYICON). #include <WinAPISysWin.au3> #include <GuiImageList.au3> #Region ;**** CONSTANTS **** ; THUMBBUTTONFLAGS Used by THUMBBUTTON to control specific states and behaviors of the button. Global Enum $THBF_ENABLED, $THBF_DISABLED, $THBF_DISMISSONCLICK, $THBF_NOBACKGROUND = 4, $THBF_HIDDEN = 8, $THBF_NONINTERACTIVE = 10 ; THUMBBUTTONMASK Used by the THUMBBUTTON structure to specify which members of that structure contain valid data. Global Enum $THB_BITMAP = 1, $THB_ICON, $THB_TOOLTIP = 4, $THB_FLAGS = 8 ; Used by the ITaskbarList3::SetProgressState method to specify tab properties. Global Enum $TBPF_NOPROGRESS, $TBPF_INDETERMINATE, $TBPF_NORMAL, $TBPF_ERROR = 4, $TBPF_PAUSED = 8 ; Used by the ITaskbarList4::SetTabProperties method to specify tab properties. Global Enum $STPF_NONE, $STPF_USEAPPTHUMBNAILALWAYS, $STPF_USEAPPTHUMBNAILWHENACTIVE, $STPF_USEAPPPEEKALWAYS = 4, $STPF_USEAPPPEEKWHENACTIVE = 8 Global Const $sCLSID_TaskbarList = "{56FDF344-FD6D-11D0-958A-006097C9A090}" ; Win2000 Global Const $sIID_ITaskbarList2 = "{602D4995-B13A-429b-A66E-1935E44F4317}" ; WinXP Global Const $sIID_ITaskbarList3 = "{EA1AFB91-9E28-4B86-90E9-9E9F8A5EEFAF}" ; Win7 Global Const $sIID_ITaskbarList4 = "{C43DC798-95D1-4BEA-9030-BB99E2983A1A}" ; Win7 Global Const $tagITaskbarList = _ "HrInit hresult();" & _ "AddTab hresult(hwnd);" & _ "DeleteTab hresult(hwnd);" & _ "ActivateTab hresult(hwnd);" & _ "SetActiveAlt hresult(hwnd);" Global Const $tagITaskbarList2 = $tagITaskbarList & _ "MarkFullscreenWindow hresult(hwnd;boolean);" Global Const $tagITaskbarList3 = $tagITaskbarList2 & _ "SetProgressValue hresult(hwnd;uint64;uint64);" & _ "SetProgressState hresult(hwnd;int);" & _ "RegisterTab hresult(hwnd;hwnd);" & _ "UnregisterTab hresult(hwnd);" & _ "SetTabOrder hresult(hwnd;hwnd);" & _ "SetTabActive hresult(hwnd;hwnd;dword);" & _ "ThumbBarAddButtons hresult(hwnd;uint;ptr);" & _ "ThumbBarUpdateButtons hresult(hwnd;uint;ptr);" & _ "ThumbBarSetImageList hresult(hwnd;ptr);" & _ "SetOverlayIcon hresult(hwnd;ptr;wstr);" & _ "SetThumbnailTooltip hresult(hwnd;wstr);" & _ "SetThumbnailClip hresult(hwnd;ptr);" Global Const $tagITaskbarList4 = $tagITaskbarList3 & _ "SetTabProperties hresult(hwnd;int);" ; Used by methods of the ITaskbarList3 interface to define buttons used in a toolbar embedded in a window's thumbnail representation. Global Const $tagTHUMBBUTTON = "dword dwMask;" & _ "uint iId;" & _ "uint iBitmap;" & _ "handle hIcon;" & _ "wchar szTip[260];" & _ "dword dwFlags" #EndRegion ;**** CONSTANTS **** Global Const $g__oTB = __TB_Init() ; #INTERNAL_USE_ONLY# ----------------------------------------------------------------------------------------------------------- ; Name...........: __TB_Init() ; Description....: Initializes the taskbar list object. ; Syntax.........: __TB_Init() ; Parameters.....: None. ; Return values..: $oTB, an object representing the taskbar list. ; Author ........: ioa747 ; Notes .........: ; Link ..........: https://learn.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-itaskbarlist-hrinit ;-------------------------------------------------------------------------------------------------------------------------------- Func __TB_Init() Local $oTB = ObjCreateInterface($sCLSID_TaskbarList, $sIID_ITaskbarList3, $tagITaskbarList3) $oTB.HrInit() Return $oTB EndFunc ;==>__TB_Init #Region ;**** ITaskbarList interface **** ; #FUNCTION# -------------------------------------------------------------------------------------------------------------------- ; Name...........: TB_ActivateTab ; Description....: Activates an item on the taskbar. The window is not actually activated. ; Syntax.........: TB_ActivateTab($hWnd) ; Parameters.....: $hWnd - Handle to the tab control. ; Return values..: Success - Returns a zero value if successful ; Failure - Returns a non-zero value indicating the error code. ; Author ........: ioa747 ; Notes .........: ; Link ..........: https://learn.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-itaskbarlist-activatetab ;-------------------------------------------------------------------------------------------------------------------------------- Func TB_ActivateTab($hWnd) Return $g__oTB.ActivateTab($hWnd) EndFunc ;==>TB_ActivateTab ; #FUNCTION# -------------------------------------------------------------------------------------------------------------------- ; Name...........: TB_AddTab ; Description....: Adds a new tab to the taskbar. ; Syntax.........: TB_AddTab($hWnd) ; Parameters.....: $hWnd - A handle to the window to be added to the taskbar. ; Return values..: Success - Returns a zero value if successful ; Failure - Returns a non-zero value indicating the error code. ; Author ........: ioa747 ; Notes .........: ; Link ..........: https://learn.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-itaskbarlist-addtab ;-------------------------------------------------------------------------------------------------------------------------------- Func TB_AddTab($hWnd) Return $g__oTB.AddTab($hWnd) EndFunc ;==>TB_AddTab ; #FUNCTION# -------------------------------------------------------------------------------------------------------------------- ; Name...........: TB_DeleteTab ; Description....: Deletes a tab from the taskbar. ; Syntax.........: DeleteTab($hWnd) ; Parameters.....: $hWnd - A handle to the window to be deleted from the taskbar. ; Return values..: Success - Returns a zero value if successful ; Failure - Returns a non-zero value indicating the error code. ; Author ........: ioa747 ; Notes .........: ; Link ..........: https://learn.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-itaskbarlist-deletetab ;-------------------------------------------------------------------------------------------------------------------------------- Func TB_DeleteTab($hWnd) Return $g__oTB.DeleteTab($hWnd) EndFunc ;==>TB_DeleteTab ; #FUNCTION# -------------------------------------------------------------------------------------------------------------------- ; Name...........: TB_SetActiveAlt ; Description....: Sets the active alternate for a toolbar control. ; Syntax.........: TB_SetActiveAlt($hWnd) ; Parameters.....: $hWnd - A handle to the window to be marked as active. ; Return values..: Success - Returns a zero value if successful ; Failure - Returns a non-zero value indicating the error code. ; Author ........: ioa747 ; Notes .........: This function is only available on Windows Win2000 and later versions of the operating system. ; Link ..........: https://learn.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-itaskbarlist-setactivealt ;-------------------------------------------------------------------------------------------------------------------------------- Func TB_SetActiveAlt($hWnd) Return $g__oTB.SetActiveAlt($hWnd) EndFunc ;==>TB_SetActiveAlt #EndRegion ;**** ITaskbarList interface **** #Region ;**** ITaskbarList2 interface **** ; #FUNCTION# -------------------------------------------------------------------------------------------------------------------- ; Name...........: TB_MarkFullscreenWindow ; Description....: Marks a window as fullscreen. ; Syntax.........: TB_MarkFullscreenWindow($hWnd, $bFullscreen) ; Parameters.....: $hWnd - The handle of the window to be marked. ; $bFullscreen - Boolean value indicating whether the window should be marked as fullscreen (True) or not (False). ; Return values..: Success - Returns a zero value if successful ; Failure - Returns a non-zero value indicating the error code. ; Author ........: ioa747 ; Notes .........: his function is only available on Windows WinXP and later versions of the operating system. ; Link ..........: https://learn.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-itaskbarlist2-markfullscreenwindow ;-------------------------------------------------------------------------------------------------------------------------------- Func TB_MarkFullscreenWindow($hWnd, $bFullscreen) Return $g__oTB.MarkFullscreenWindow($hWnd, $bFullscreen) EndFunc ;==>TB_MarkFullscreenWindow #EndRegion ;**** ITaskbarList2 interface **** #Region ;**** ITaskbarList3 interface **** ; #FUNCTION# -------------------------------------------------------------------------------------------------------------------- ; Name...........: TB_RegisterTab ; Description....: Registers a tab in the thumbnail toolbar. ; Syntax.........: TB_RegisterTab($hWndTab, $hWndMDI) ; Parameters.....: $hWndTab - Handle to the tab window. ; $hWndMDI - The handle of the main window (the MDI client area). ; Return values..: Success - Returns a zero value if successful ; Failure - Returns a non-zero value indicating the error code. ; Author ........: ioa747 ; Notes .........: ; Link ..........: https://learn.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-itaskbarlist3-registertab ;-------------------------------------------------------------------------------------------------------------------------------- Func TB_RegisterTab($hWndTab, $hWndMDI) Return $g__oTB.RegisterTab($hWndTab, $hWndMDI) EndFunc ;==>TB_RegisterTab ; #FUNCTION# -------------------------------------------------------------------------------------------------------------------- ; Name...........: TB_SetOverlayIcon ; Description....: Sets the overlay icon for a toolbar button. ; Syntax.........: TB_SetOverlayIcon($hWnd, $hIcon, $sAltText = "") ; Parameters.....: $hWnd - The handle of the window whose associated taskbar button receives the overlay. ; $hIcon - Handle to the icon to be used as the overlay image. ; $sAltText - Alternative text for the button. If this parameter is an empty string, ; the function will use the current value of the TB_SETTOOLTIPS message. ; Return values..: Success - Returns a zero value if successful ; Failure - Returns a non-zero value indicating the error code. ; Author ........: ioa747 ; Notes .........: This function is only available on Windows Vista and later. ; Link ..........: https://learn.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-itaskbarlist3-setoverlayicon ;-------------------------------------------------------------------------------------------------------------------------------- Func TB_SetOverlayIcon($hWnd, $hIcon, $sAltText = "") Return $g__oTB.SetOverlayIcon($hWnd, $hIcon, $sAltText) EndFunc ;==>TB_SetOverlayIcon ; #FUNCTION# -------------------------------------------------------------------------------------------------------------------- ; Name...........: TB_SetProgressState ; Description....: Sets the progress state of a taskbar button. ; Syntax.........: TB_SetProgressState($hWnd, $iFlags) ; Parameters.....: $hWnd - The handle of the window in which the progress of an operation is being shown. ; $iFlags - Flags that specify the new progress state. Can be one of the following values: ; | (0) $TBPF_NOPROGRESS - Stops displaying progress and returns the button to its normal state. ; | (1) $TBPF_INDETERMINATE - The progress indicator does not grow in size, but cycles repeatedly along the length of the taskbar button. ; | (2) $TBPF_NORMAL - The progress indicator grows in size from left to right in proportion to the estimated amount of the operation completed. ; | (4) $TBPF_ERROR - The progress indicator turns red to show that an error has occurred in one of the windows that is broadcasting progress. ; | (8) $TBPF_PAUSED - The progress indicator turns yellow to show that progress is currently stopped in one of the windows but can be resumed by the user. ; Return values..: Success - Returns a zero value if successful ; Failure - Returns a non-zero value indicating the error code. ; Author ........: ioa747 ; Notes .........: ; Link ..........: https://learn.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-itaskbarlist3-setprogressstate ;-------------------------------------------------------------------------------------------------------------------------------- Func TB_SetProgressState($hWnd, $iFlags) Return $g__oTB.SetProgressState($hWnd, $iFlags) EndFunc ;==>TB_SetProgressState ; #FUNCTION# -------------------------------------------------------------------------------------------------------------------- ; Name...........: TB_SetProgress ; Description....: Sets the progress value of a taskbar button. ; Syntax.........: TB_SetProgress($hWnd, $iCurrent, $iCompleted) ; Parameters.....: $hWnd - The handle of the window whose associated taskbar button is being used as a progress indicator. ; $iCurrent - The current progress value. ; $iCompleted - The completed progress value. ; Return values..: Success - Returns a zero value if successful ; Failure - Returns a non-zero value indicating the error code. ; Author ........: nine ; Notes .........: ; Link ..........: https://www.autoitscript.com/forum/topic/139260-autoit-snippets/page/26/#comment-1536397 ;-------------------------------------------------------------------------------------------------------------------------------- Func TB_SetProgress($hWnd, $iCurrent, $iCompleted) Return $g__oTB.SetProgressValue($hWnd, $iCurrent, $iCompleted) EndFunc ;==>TB_SetProgress ; #FUNCTION# -------------------------------------------------------------------------------------------------------------------- ; Name...........: TB_SetTabActive ; Description....: Sets the active tab in a thumbnail tooltip control. ; Syntax.........: TB_SetTabActive($hWndTab, $hWndMDI, $iReserved = 0) ; Parameters.....: $hWndTab - Handle of the active tab window. This handle must already be registered through RegisterTab. ; $hWndMDI - The handle of the main window (the MDI client area). ; $iReserved - Reserved for future use. Must be set to zero. ; Return values..: Success - Returns a zero value if successful ; Failure - Returns a non-zero value indicating the error code. ; Author ........: ioa747 ; Notes .........: Note that this function is likely only useful in the context of an MDI application, ; where multiple tabs are managed by a single client area. ; Link ..........: https://learn.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-itaskbarlist3-settabactive ;-------------------------------------------------------------------------------------------------------------------------------- Func TB_SetTabActive($hWndTab, $hWndMDI, $iReserved = 0) Return $g__oTB.SetTabActive($hWndTab, $hWndMDI, $iReserved) EndFunc ;==>TB_SetTabActive ; #FUNCTION# -------------------------------------------------------------------------------------------------------------------- ; Name...........: TB_SetTabOrder ; Description....: Sets the tab order of a toolbar control. ; Syntax.........: TB_SetTabOrder($hWndTab, $hWndInsertBefore) ; Parameters.....: $hWndTab - The handle of the tab window whose thumbnail is being placed. This value is required, must already be registered through ITaskbarList3::RegisterTab ; $hWndInsertBefore - Handle to the window that will precede the specified window in the tab order. ; Return values..: Success - Returns a zero value if successful ; Failure - Returns a non-zero value indicating the error code. ; Author ........: ioa747 ; Notes .........: ; Link ..........: https://learn.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-itaskbarlist3-settaborder ;-------------------------------------------------------------------------------------------------------------------------------- Func TB_SetTabOrder($hWndTab, $hWndInsertBefore) Return $g__oTB.SetTabOrder($hWndTab, $hWndInsertBefore) EndFunc ;==>TB_SetTabOrder ; #FUNCTION# -------------------------------------------------------------------------------------------------------------------- ; Name...........: TB_SetThumbnailClip ; Description....: Selects a portion of a window's client area to display as that window's thumbnail in the taskbar. ; Syntax.........: TB_SetThumbnailClip($hWnd, $iLeft, $iTop, $iRight, $iBottom) ; Parameters.....: $hWnd - The handle to a window represented in the taskbar. ; $iLeft - The left coordinate of the clipping rectangle. ; $iTop - The top coordinate of the clipping rectangle. ; $iRight - The right coordinate of the clipping rectangle. ; $iBottom - The bottom coordinate of the clipping rectangle. ; Return values..: Success - Returns a zero value if successful ; Failure - Returns a non-zero value indicating the error code. ; Author ........: ioa747 ; Notes .........: ; Link ..........: https://learn.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-itaskbarlist3-setthumbnailclip ;-------------------------------------------------------------------------------------------------------------------------------- Func TB_SetThumbnailClip($hWnd, $iLeft, $iTop, $iRight, $iBottom) Local $tRECTClip = DllStructCreate($tagRECT) DllStructSetData($tRECTClip, "Left", $iLeft) DllStructSetData($tRECTClip, "Top", $iTop) DllStructSetData($tRECTClip, "Right", $iRight) DllStructSetData($tRECTClip, "Bottom", $iBottom) Return $g__oTB.SetThumbnailClip($hWnd, DllStructGetPtr($tRECTClip)) EndFunc ;==>TB_SetThumbnailClip ; #FUNCTION# -------------------------------------------------------------------------------------------------------------------- ; Name...........: TB_SetThumbnailTooltip ; Description....: Sets a tooltip for a thumbnail in the taskbar. ; Syntax.........: TB_SetThumbnailTooltip($hWnd, $sTooltip) ; Parameters.....: $hWnd - Handle to the window that contains the thumbnail. ; $sTooltip - Tooltip text to be displayed. ; Return values..: Success - Returns a zero value if successful ; Failure - Returns a non-zero value indicating the error code. ; Author ........: ioa747 ; Notes .........: The tooltip will be displayed when the user hovers their mouse over the thumbnail. ; Link ..........: https://learn.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-itaskbarlist3-setthumbnailtooltip ;-------------------------------------------------------------------------------------------------------------------------------- Func TB_SetThumbnailTooltip($hWnd, $sTooltip) Return $g__oTB.SetThumbnailTooltip($hWnd, $sTooltip) EndFunc ;==>TB_SetThumbnailTooltip ; #FUNCTION# -------------------------------------------------------------------------------------------------------------------- ; Name...........: TB_ThumbBarAddButtons ; Description....: Adds buttons to the thumbnail toolbar. ; Syntax.........: TB_ThumbBarAddButtons($hWnd, $iButtonCount, $aButtons) ; Parameters.....: $hWnd - Handle to the window that contains the thumbnail image. ; $iButtonCount - Number of buttons to add. ; $aButtons - Array of button data. Each element in the array should be a structure with the following fields: ; - dwMask - Mask of valid fields in this structure. Can be a combination of THUMBBUTTONMASK ; $THB_BITMAP = 1, $THB_ICON, $THB_TOOLTIP = 4, $THB_FLAGS = 8 ; - iId - Unique identifier for the button. This value is returned in the $iButtonIndex parameter of the TB_ThumbBarButtonPressed notification code. ; - iBitmap - Handle to the bitmap that will be displayed on the button. ; - hIcon - Handle to the icon that will be displayed on the button. ; - szTip - Tooltip text for the button. ; - dwFlags - Flags that specify the behavior of the button. Can be a combination of THUMBBUTTONFLAGS ; $THBF_ENABLED=0, $THBF_DISABLED=1, $THBF_DISMISSONCLICK=2, $THBF_NOBACKGROUND=4, $THBF_HIDDEN=8, $THBF_NONINTERACTIVE=10. ; Return values..: Success - Returns a zero value if successful ; Failure - Returns a non-zero value indicating the error code. ; Author ........: ioa747 ; Notes .........: ; Link ..........: https://learn.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-itaskbarlist3-thumbbaraddbuttons ;-------------------------------------------------------------------------------------------------------------------------------- Func TB_ThumbBarAddButtons($hWnd, $iButtonCount, $aButtons) ; Create a struct for each button ; dwFlags(THBF_ENABLED=0, THBF_DISABLED=0x1, THBF_DISMISSONCLICK=0x2, THBF_NOBACKGROUND=0x4, THBF_HIDDEN=0x8, THBF_NONINTERACTIVE=0x10) ; Get the size of the THUMBBUTTON structure Local $iStructSize = DllStructGetSize(DllStructCreate($tagTHUMBBUTTON)) ; Calculate the total memory size needed for all button structures Local $pButtonsMemory = DllStructCreate("byte[" & ($iStructSize * $iButtonCount) & "]") If @error Then MsgBox(16, "Error", "Failed to create memory structure for buttons. Error: " & @error) Return EndIf ; Loop through and initialize each button structure For $i = 0 To $iButtonCount - 1 ; Create a THUMBBUTTON struct at the correct memory location Local $pCurrentButton = DllStructCreate($tagTHUMBBUTTON, DllStructGetPtr($pButtonsMemory) + ($iStructSize * $i)) If @error Then MsgBox(16, "Error", "Failed to create DllStruct for button " & ($i + 1) & ". Error: " & @error) Return EndIf ; Populate the struct with button data DllStructSetData($pCurrentButton, "dwMask", $aButtons[$i][0]) DllStructSetData($pCurrentButton, "iId", $aButtons[$i][1]) DllStructSetData($pCurrentButton, "iBitmap", $aButtons[$i][2]) DllStructSetData($pCurrentButton, "hIcon", $aButtons[$i][3]) DllStructSetData($pCurrentButton, "szTip", $aButtons[$i][4]) DllStructSetData($pCurrentButton, "dwFlags", $aButtons[$i][5]) ; Validate if data was set correctly If @error Then MsgBox(16, "Error", "Failed to set data for button " & ($i + 1) & ". Error: " & @error) Return EndIf Next ; Call the ThumbBarAddButtons method Local $hResult = $g__oTB.ThumbBarAddButtons($hWnd, $iButtonCount, DllStructGetPtr($pButtonsMemory)) If $hResult <> 0 Then MsgBox(16, "Error", "Failed to add thumbnail toolbar buttons. HRESULT: " & $hResult) EndIf EndFunc ;==>TB_ThumbBarAddButtons ; #FUNCTION# -------------------------------------------------------------------------------------------------------------------- ; Name...........: TB_ThumbBarSetImageList ; Description....: Sets the image list for a thumb bar. ; Syntax.........: TB_ThumbBarSetImageList($hWnd, $hImageList) ; Parameters.....: $hWnd - The handle of the window whose thumbnail representation contains the toolbar to be updated. ; $hImageList - Handle to an image list containing the images for the thumb bar. ; Return values..: Success - Returns a zero value if successful ; Failure - Returns a non-zero value indicating the error code. ; Author ........: ioa747 ; Notes .........: ; Link ..........: https://learn.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-itaskbarlist3-thumbbarsetimagelist ;-------------------------------------------------------------------------------------------------------------------------------- Func TB_ThumbBarSetImageList($hWnd, $hImageList) $g__oTB.ThumbBarSetImageList($hWnd, $hImageList) EndFunc ;==>TB_ThumbBarSetImageList ; #FUNCTION# -------------------------------------------------------------------------------------------------------------------- ; Name...........: TB_ThumbBarUpdateButtons ; Description....: Updates the buttons in a thumbnail toolbar. ; Syntax.........: TB_ThumbBarUpdateButtons($hWnd, $iButtonCount, $aButtons) ; Parameters.....: $hWnd - The handle of the window whose thumbnail representation contains the toolbar. ; $iButtonCount- Number of buttons in the array. ; $aButtons - Array of button data. Each element in the array should be a structure with the following fields: ; - dwMask - Mask of valid fields in this structure. Can be a combination of THUMBBUTTONMASK ; $THB_BITMAP = 1, $THB_ICON, $THB_TOOLTIP = 4, $THB_FLAGS = 8 ; - iId - Unique identifier for the button. This value is returned in the $iButtonIndex parameter of the TB_ThumbBarButtonPressed notification code. ; - iBitmap - Handle to the bitmap that will be displayed on the button. ; - hIcon - Handle to the icon that will be displayed on the button. ; - szTip - Tooltip text for the button. ; - dwFlags - Flags that specify the behavior of the button. Can be a combination of THUMBBUTTONFLAGS ; $THBF_ENABLED=0, $THBF_DISABLED=1, $THBF_DISMISSONCLICK=2, $THBF_NOBACKGROUND=4, $THBF_HIDDEN=8, $THBF_NONINTERACTIVE=10. ; Return values..: Success - Returns a zero value if successful ; Failure - Returns a non-zero value indicating the error code. ; Author ........: ioa747 ; Notes .........: ; Link ..........: https://learn.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-itaskbarlist3-thumbbarupdatebuttons ;-------------------------------------------------------------------------------------------------------------------------------- Func TB_ThumbBarUpdateButtons($hWnd, $iButtonCount, $aButtons) ; Create a struct for each button ; dwFlags(THBF_ENABLED=0, THBF_DISABLED=0x1, THBF_DISMISSONCLICK=0x2, THBF_NOBACKGROUND=0x4, THBF_HIDDEN=0x8, THBF_NONINTERACTIVE=0x10) ; Get the size of the THUMBBUTTON structure Local $iStructSize = DllStructGetSize(DllStructCreate($tagTHUMBBUTTON)) ; Calculate the total memory size needed for all button structures Local $pButtonsMemory = DllStructCreate("byte[" & ($iStructSize * $iButtonCount) & "]") If @error Then MsgBox(16, "Error", "Failed to create memory structure for buttons. Error: " & @error) Return EndIf ; Loop through and initialize each button structure For $i = 0 To $iButtonCount - 1 ; Create a THUMBBUTTON struct at the correct memory location Local $pCurrentButton = DllStructCreate($tagTHUMBBUTTON, DllStructGetPtr($pButtonsMemory) + ($iStructSize * $i)) If @error Then MsgBox(16, "Error", "Failed to create DllStruct for button " & ($i + 1) & ". Error: " & @error) Return EndIf ; Populate the struct with button data DllStructSetData($pCurrentButton, "dwMask", $aButtons[$i][0]) DllStructSetData($pCurrentButton, "iId", $aButtons[$i][1]) DllStructSetData($pCurrentButton, "iBitmap", $aButtons[$i][2]) DllStructSetData($pCurrentButton, "hIcon", $aButtons[$i][3]) DllStructSetData($pCurrentButton, "szTip", $aButtons[$i][4]) DllStructSetData($pCurrentButton, "dwFlags", $aButtons[$i][5]) ; Validate if data was set correctly If @error Then MsgBox(16, "Error", "Failed to set data for button " & ($i + 1) & ". Error: " & @error) Return EndIf Next ; Call the ThumbBarUpdateButtons method Local $hResult = $g__oTB.ThumbBarUpdateButtons($hWnd, $iButtonCount, DllStructGetPtr($pButtonsMemory)) If $hResult <> 0 Then MsgBox(16, "Error", "Failed to Update thumbnail toolbar buttons. HRESULT: " & $hResult) EndIf EndFunc ;==>TB_ThumbBarUpdateButtons ; #FUNCTION# -------------------------------------------------------------------------------------------------------------------- ; Name...........: TB_UnregisterTab ; Description....: Unregisters a tab from the toolbar. ; Syntax.........: TB_UnregisterTab($hWndTab) ; Parameters.....: $hWndTab - The handle of the tab window whose thumbnail is being removed. ; This is the same value with which the thumbnail was registered as part the group through RegisterTab ; Return values..: Success - Returns a zero value if successful ; Failure - Returns a non-zero value indicating the error code. ; Author ........: ioa747 ; Notes .........: ; Link ..........: https://learn.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-itaskbarlist3-unregistertab ;-------------------------------------------------------------------------------------------------------------------------------- Func TB_UnregisterTab($hWndTab) Return $g__oTB.UnregisterTab($hWndTab) EndFunc ;==>TB_UnregisterTab #EndRegion ;**** ITaskbarList3 interface **** #Region ;**** ITaskbarList4 interface **** ; #FUNCTION# -------------------------------------------------------------------------------------------------------------------- ; Name...........: TB_SetTabProperties ; Description....: Sets the properties of a tab in a toolbar control. ; Syntax.........: TB_SetTabProperties($hWndTab, $stpFlags) ; Parameters.....: $hWndTab - The handle of the tab window that is to have properties set. This handle must already be registered through RegisterTab. ; $stpFlags - A combination of the following values: ; |(0) STPF_NONE : No specific property values are specified. ; The default behavior is used: the tab window provides a thumbnail and peek image, either live or static as appropriate. ; |(1) $STPF_USEAPPTHUMBNAILALWAYS : Always use the thumbnail provided by the main application frame window rather than a thumbnail provided by the individual tab window. ; Do not combine this value with STPF_USEAPPTHUMBNAILWHENACTIVE; doing so will result in an error. ; |(2) $STPF_USEAPPTHUMBNAILWHENACTIVE : When the application tab is active and a live representation of its window is available, ; use the main application's frame window thumbnail. At other times, use the tab window thumbnail. ; Do not combine this value with STPF_USEAPPTHUMBNAILALWAYS; doing so will result in an error. ; |(4) $STPF_USEAPPPEEKALWAYS : Always use the peek image provided by the main application frame window rather than a peek image provided by the individual tab window. ; Do not combine this value with STPF_USEAPPPEEKWHENACTIVE; doing so will result in an error. ; |(8) $STPF_USEAPPPEEKWHENACTIVE : When the application tab is active and a live representation of its window is available, ; show the main application frame in the peek feature. At other times, use the tab window. ; Do not combine this value with STPF_USEAPPPEEKALWAYS; doing so will result in an error. ; Return values..: Success - Returns a zero value if successful ; Failure - Returns a non-zero value indicating the error code. ; Author ........: ioa747 ; Notes .........: ; Link ..........: https://learn.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-itaskbarlist4-settabproperties ;-------------------------------------------------------------------------------------------------------------------------------- Func TB_SetTabProperties($hWndTab, $stpFlags) Return $g__oTB.SetTabProperties($hWndTab, $stpFlags) EndFunc ;==>TB_SetTabProperties #EndRegion ;**** ITaskbarList4 interface **** #Region ;**** Extra **** ; #FUNCTION# -------------------------------------------------------------------------------------------------------------------- ; Name...........: TB_Flash ; Description....: Flashes a taskbar button. ; Syntax.........: TB_Flash($hWnd, $iTimes = 3, $iDelay = 300) ; Parameters.....: $hWnd - Handle to the taskbar button. ; $iTimes - Number of times to flash (default is 3). ; $iDelay - Delay between flashes in milliseconds (default is 300). ; Return values..: None. ; Author ........: nine ; Notes .........: This function uses the TaskbarButton class to interact with taskbar buttons. For more information, see the AutoIt documentation. ; Link ..........: https://www.autoitscript.com/forum/topic/139260-autoit-snippets/page/26/#comment-1536397 ;-------------------------------------------------------------------------------------------------------------------------------- Func TB_Flash($hWnd, $iTimes = 3, $iDelay = 300) For $i = 1 To $iTimes $g__oTB.SetProgressState($hWnd, 0) Sleep($iDelay) $g__oTB.SetProgressValue($hWnd, 100, 100) Sleep($iDelay) Next $g__oTB.SetProgressState($hWnd, 0) EndFunc ;==>TB_Flash ; #FUNCTION# -------------------------------------------------------------------------------------------------------------------- ; Name...........: TB_GetIconHandle ; Description....: Returns a handle to an icon. ; Syntax.........: TB_GetIconHandle($iconFilePath, $iconIndex = 0) ; Parameters.....: $iconFilePath - The path of the file that contains the icon. ; $iconIndex - The index of the icon in the file. Default is 0. ; Return values..: Success - A handle to the icon. ; Failure - 0, and sets @error to 1. ; Author ........: ioa747 ; Notes .........: This function uses the ExtractIcon function from the shell32.dll library. ; Link ..........: https://docs.microsoft.com/en-us/windows/win32/api/shellapi/nf-shellapi-extracticona ; Dependencies...: _WinAPI_GetModuleHandle, DllCall ;-------------------------------------------------------------------------------------------------------------------------------- Func TB_GetIconHandle($iconFilePath, $iconIndex = 0) Local $hInstance = _WinAPI_GetModuleHandle(0) Local $aResult = DllCall("shell32.dll", "hwnd", "ExtractIcon", "hwnd", $hInstance, "str", $iconFilePath, "uint", $iconIndex) If @error Then Return SetError(1, 0, 0) EndIf Return $aResult[0] EndFunc ;==>TB_GetIconHandle #EndRegion ;**** Extra **** Please, every comment is appreciated! leave your comments and experiences here! Thank you very much ITaskbarList_V3.7z
    1 point
  3. Hi everybody Yesterday I found a script from @Melba23 where he used Ellipsis styles (3 dots) for label controls and I never heard about them before. Here is the script, where I added code for 3rd/4th labels and comments : #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $spath = "C:\I am a very long path\Which needs to be\Shortened to fit\In the label.txt" $hGUI = GUICreate("Test on ellipsis (3 dots)", 500, 250) GUICtrlCreateLabel($sPath, 10, 10, 300, 40, $DT_PATH_ELLIPSIS) ; in fact SS_ENDELLIPSIS GUICtrlSetBkColor(-1, 0xC0FFFF) GUICtrlCreateLabel($sPath, 10, 70, 300, 40, $DT_END_ELLIPSIS) ; in fact SS_PATHELLIPSIS GUICtrlSetBkColor(-1, 0xFFFF00) GUICtrlCreateLabel($sPath, 10, 130, 300, 40, $DT_WORD_ELLIPSIS) ; 0x00040000 (but this is the WS_SIZEBOX style, nice effect on label !) GUICtrlSetBkColor(-1, 0xC0FF00) GUICtrlCreateLabel($sPath, 10, 190, 300, 40, 0x0000C000) ; SS_WORDELLIPSIS GUICtrlSetBkColor(-1, 0xC0FFFF) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd #cs Melba23's comments : "Note that I am pretty sure the 2 values [$DT_PATH_ELLIPSIS and $DT_END_ELLIPSIS] have been reversed in the [Windows]Constants file as I would have labelled them the other way round. But MS work in strange ways and perhaps they really are that way." :) My research : 1) Found in WindowsConstants.au3 and in WinUser.h : DrawText() Format Flags #define DT_PATH_ELLIPSIS 0x00004000 #define DT_END_ELLIPSIS 0x00008000 #define DT_WORD_ELLIPSIS 0x00040000 2) Not found in WindowsConstants.au3 but found in WinUser.h : Static Control Constants #define SS_ENDELLIPSIS 0x00004000 #define SS_PATHELLIPSIS 0x00008000 #define SS_WORDELLIPSIS 0x0000C000 #ce imho the Ellipsis styles applied to label (static) controls should be the ones found on msdn page (i.e. Static Control Styles : SS_ENDELLIPSIS, SS_PATHELLIPSIS and SS_WORDELLIPSIS) but not the ones found in the script above (DT_END_ELLIPSIS, DT_PATH_ELLIPSIS and DT_WORD_ELLIPSIS) which should be applied to the Draw Text function. First of all, the corresponding styles don't have the same value (see comments at the end of the script) though it's not an issue in this case for two of them, as both 0x00004000 and 0x00008000 can't be mixed with GUI styles, but what about the 3rd ellipsis style (the Word ellipsis style) ? See what happens in the script when I wrongly use the DT_WORD_ELLIPSIS style for the 3rd label : It's value of 0x00040000 is the same as the WS_SIZEBOX Gui style (0x00040000) . That's why we see the 3rd label with a raised edge and a sizing border, which doesn't look bad at all (I'll have to remember that !) but the style did not fulfill its role. The 4th label shows the style that should be applied : SS_WORDELLIPSIS (0x0000C000) instead of DT_WORD_ELLIPSIS (0x00040000) For the record, as I didn't see any display difference between label 1 (SS_ENDELLIPSIS) and label 4 (SS_WORDELLIPSIS) then I searched on the Web and found this link on Stackoverflow If you're curious to see a difference between both styles, you can try this on the _WinAPI_DrawText example, with the following change (not the best change but well... at least we can see different displays) : _WinAPI_DrawText($g_hDC, "Hello world!", $g_tRECT, $DT_CENTER) ; original line in help file example ; _WinAPI_DrawText($g_hDC, "Hi" & @crlf & " world, how are you ?", $g_tRECT, $DT_END_ELLIPSIS) ; _WinAPI_DrawText($g_hDC, "Hi" & @crlf & " world, how are you ?", $g_tRECT, $DT_WORD_ELLIPSIS) Thanks Melba23 for this Ellipsis discovery and just feel free to comment if I wrote anything wrong. Have a great week-end
    1 point
  4. you might find it interesting https://www.autoitscript.com/forum/topic/211276-taskpin/#comments
    1 point
  5. Rad, [Techie solution!] Use the ELLIPSIS styles: #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $spath = "C:\I am a very long path\Which needs to be\Shortened to fit\In the label.txt" $hGUI = GUICreate("Test", 500, 500) GUICtrlCreateLabel($sPath, 10, 10, 300, 30, $DT_PATH_ELLIPSIS) GUICtrlCreateLabel($sPath, 10, 50, 300, 30, $DT_END_ELLIPSIS) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEndNote that I am pretty sure the 2 values have been reversed in the Constants file as I would have labelled them the other way round. But MS work in strange ways and perhaps they really are that way. M23
    1 point
×
×
  • Create New...