Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 12/16/2024 in all areas

  1. Hi all, I've just been playing with window messages that are sent to win32 controls themselves (rather than to the parent GUI), and it looks like you can do some cool stuff. So I thought I'd share some things that I found interesting. And yeah I know the code probably needs a cleanup - but I figure its good enough to get the point across... Anyway what I have is: while the "lock" checkbox is selected, the buttons behave normally. Otherwise you can drag them around and/or resize them. Because you're essentially dragging the buttons by their "Caption" bar, double clicking will also maximise them. #include <guiConstants.au3> #include <winapi.au3> Global Const $DLGC_BUTTON = 0x2000 Global Const $DLGC_WANTTAB = 0x0002 Global $hGui = GUICreate("", 300, 200) Global $idBtn = GUICtrlCreateButton("Button 1", 4, 4, 80, 80) Global $idBtn2 = GUICtrlCreateButton("Button 2", 90, 4, 80, 80) Global $idLockButtons = GUICtrlCreateCheckbox("Lock Buttons", 200, 20, 80, 20) Global $hCursor = _WinAPI_CopyCursor(_WinAPI_LoadCursor(0, $OCR_CROSS)) Global $hBtnMoveProc = DllCallbackRegister("ButtonMoveProc", "long", "hwnd;uint;wparam;lparam") Global $pBtnMoveProc = DllCallbackGetPtr($hBtnMoveProc) Global $hBtn = GUICtrlGetHandle($idBtn) Global $hBtn2 = GUICtrlGetHandle($idBtn2) Global $pOrigBtnProc = _WinAPI_SetWindowLong($hBtn, $GWL_WNDPROC, $pBtnMoveProc) _WinAPI_SetWindowLong($hBtn2, $GWL_WNDPROC, $pBtnMoveProc) GUISetState() While 1 Local $iMsg = GUIGetMsg() Switch $iMsg Case $GUI_EVENT_CLOSE Exit Case $idLockButtons _WinAPI_SetWindowLong($hBtn, $GWL_WNDPROC, (GUICtrlRead($iMsg) = $GUI_CHECKED) ? $pOrigBtnProc : $pBtnMoveProc) _WinAPI_SetWindowLong($hBtn2, $GWL_WNDPROC, (GUICtrlRead($iMsg) = $GUI_CHECKED) ? $pOrigBtnProc : $pBtnMoveProc) Case $idBtn, $idBtn2 ConsoleWrite("Click " & GUICtrlRead($iMsg) & @CRLF) EndSwitch WEnd Func ButtonMoveProc($hWnd, $uMsg, $wParam, $lParam) Local $aPos, $iRet, $aPoint[2], $iSrc, $iEvent Local $aRes = DllCallAddress("long", $pOrigBtnProc, "hwnd", $hWnd, "uint", $uMsg, "wparam", $wParam, "lparam", $lParam) Switch $uMsg Case $WM_NCHITTEST $aPos = WinGetPos($hWnd) $aPoint[0] = BitAND($lParam, 0xFFFF) $aPoint[1] = BitShift($lParam, 16) $iRet = $HTCAPTION If $aPoint[0] - $aPos[0] < 10 Then $iRet = $HTLEFT If $aPoint[0] - $aPos[0] > ($aPos[2] - 10) Then $iRet = $HTRIGHT If $aPoint[1] - $aPos[1] < 10 Then Switch $iRet Case $HTLEFT $iRet = $HTTOPLEFT Case $HTRIGHT $iRet = $HTTOPRIGHT Case Else $iRet = $HTTOP EndSwitch ElseIf $aPoint[1] - $aPos[1] > ($aPos[3] - 10) Then Switch $iRet Case $HTLEFT $iRet = $HTBOTTOMLEFT Case $HTRIGHT $iRet = $HTBOTTOMRIGHT Case Else $iRet = $HTBOTTOM EndSwitch EndIf Return $iRet Case $WM_SETCURSOR $iSrc = BitAND($lParam, 0xFFFF) $iEvent = BitShift($lParam, 16) If $iSrc = $HTCAPTION And $iEvent = $WM_LBUTTONDOWN Then _WinAPI_SetCursor($hCursor) Return True EndIf Case Else EndSwitch Return $aRes[0] ;~ Return _WinAPI_DefWindowProcW($hWnd, $uMsg, $wParam, $lParam) EndFunc ;==>ButtonProc
    5 points
  2. yep got it. Here a way to solve it : Case $WM_SETCURSOR $iSrc = BitAND($lParam, 0xFFFF) $iEvent = BitShift($lParam, 16) If $iSrc = $HTCAPTION And $iEvent = $WM_LBUTTONDOWN Then _WinAPI_RedrawWindow($hWnd, 0, 0, $RDW_INVALIDATE + $RDW_FRAME) $hCursor = _WinAPI_LoadCursor(0, $OCR_SIZEALL) _WinAPI_SetCursor($hCursor) Return True EndIf ps. it is not working all the times... pps. seems that solves the issue (changed code above) _WinAPI_RedrawWindow($hWnd, 0, 0, $RDW_INVALIDATE + $RDW_FRAME)
    3 points
  3. Nine

    AutoIt Snippets

    Owner Draw Combo Box with default $CBS_DROPDOWN. Not so obvious as it seems. #include <WinAPIConv.au3> #include <WinAPIGdi.au3> #include <GUIConstants.au3> #include <Constants.au3> #include <GuiComboBox.au3> Opt("MustDeclareVars", True) Global Const $tagDRAWITEMSTRUCT = "uint CtlType;uint CtlID;uint itemID;uint itemAction;uint itemState;hwnd hwndItem;handle hDC;dword rcItem[4];ptr itemData" Global Const $ODA_DRAWENTIRE = 1 Global Const $ODS_SELECTED = 1 Global $idCombo Example() Func Example() GUICreate("Owner Draw", 300, 200) $idCombo = GUICtrlCreateCombo("", 10, 10, 185, 20, BitOR($CBS_HASSTRINGS, $CBS_OWNERDRAWFIXED, $GUI_SS_DEFAULT_COMBO)) Local $idClose = GUICtrlCreateButton("Close", 210, 170, 85, 25) GUICtrlSetData($idCombo, "1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17") GUISetState() Local $aAccelKeys[1][2] = [["{ENTER}", $idCombo]] GUISetAccelerators($aAccelKeys) GUIRegisterMsg($WM_COMMAND, WM_COMMAND) GUIRegisterMsg($WM_DRAWITEM, WM_DRAWITEM) While True Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $idClose ExitLoop EndSwitch WEnd EndFunc ;==>Example Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam) Local $idCtrl = _WinAPI_LoWord($wParam), $iCode = _WinAPI_HiWord($wParam) If $idCtrl = $idCombo And ($iCode = $CBN_KILLFOCUS Or $iCode = $CBN_SELCHANGE) Then Validate($idCtrl) Return $GUI_RUNDEFMSG EndFunc ;==>WM_COMMAND Func Validate($idComboBox) Local Static $sSelection Local $sComboRead = GUICtrlRead($idComboBox) If $sSelection = $sComboRead Then Return Local $iList = _GUICtrlComboBox_FindStringExact($idComboBox, $sComboRead) If $iList = -1 Then GUICtrlSendMsg($idComboBox, $CB_SETCURSEL, -1, 0) $sSelection = "" ConsoleWrite("Invalid data" & @CRLF) Else $sSelection = $sComboRead ConsoleWrite("Currently displaying: " & $sComboRead & @CRLF) If _GUICtrlComboBox_GetCurSel($idComboBox) = -1 Then _GUICtrlComboBox_SetCurSel($idComboBox, $iList) EndIf EndFunc ;==>Validate Func WM_DRAWITEM($hWnd, $iMsg, $wParam, $lParam) If $wParam <> $idCombo Then Return $GUI_RUNDEFMSG Local $tDraw = DllStructCreate($tagDRAWITEMSTRUCT, $lParam), $sText If $tDraw.itemAction = $ODA_DRAWENTIRE Then Local $tRECT = DllStructCreate($tagRECT, DllStructGetPtr($tDraw, "rcItem")) Local $hBrush = _WinAPI_CreateSolidBrush(BitAND($tDraw.itemState, $ODS_SELECTED) ? 0xFFCDAD : Mod($tDraw.itemID, 2) ? 0xFFFFFF : 0xE0E0E0) _WinAPI_FillRect($tDraw.hDC, $tRECT, $hBrush) $tRECT.Left += 5 $tRECT.Top += 2 _GUICtrlComboBox_GetLBText($tDraw.hwndItem, $tDraw.itemID, $sText) _WinAPI_DrawText($tDraw.hDC, $sText, $tRECT, $DT_LEFT) _WinAPI_DeleteObject($hBrush) EndIf Return $GUI_RUNDEFMSG EndFunc ;==>WM_DRAWITEM Note : you can tab, enter, up arrow, down arrow to validate the combo input field.
    2 points
  4. Very nice way to play with controls. Don't know if you have tried it, but FWIW it works also perfectly with _WinAPI_SetWindowSubclass. Just tested it with same result.
    1 point
  5. The example: The UDFish: The back story: I put together "Win 11 - My own border color" and looking at the logs I've found that I had a handle leak. The leak got fixed but I wanted ( out of OCD ? ) to have the script report on it's status. Ok, easy enough, I'll IPC the request. But I don't wanna have it in the main loop, constantly asking "are we there yet ?, are we there yet ?, ..." . I could not find a copy'n'paste UDF, that did that I wanted to have, so I had to code it 🥲 Now you can copy'n'paste it How does it work: When WM_COPYDATA gets a message, it puts the data in a global array that gets accessed by any user function triggered by AdlibRegister() after X mSec. You can set the AdlibRegister() time with WMCDIPC_AdlibTime(). Without a parameter it will return the current value. Can set the user function with WMCDIPC_AdlibFunc()**. Without a parameter it will return the current value. The UDF has notes that will hint it's use. Hope you find it useful. Edit: This is v2.0 ( yey ! ) ** there now is a WMCDIPC_AdlibRegister(func,time) that can do that too. This version allows running all Au3Stripper arguments, so that's good. Added WMCDIPC_PrintCallback() to handle the one line of debug in the UDF. Also added a return in case the script is already busy running in Adlib, therefore unable to process the IPC request right there and then. The int return is "0xFADE" and the string has how many mSec it's been busy. Giving the user a chance to know it "FADEd away" and formulate a resend or what not. Since is a new version, added WMCDIPC_Version(), just in case of a future one. But all in all, I think that this UDF is complete and needs no other functionality for the scenario it would be used at. Edit: This is v2.1 ( wow ! ) Added in the loop. Why ?. Well, the project that I wrote this for is GUIOnEventMode=1. Having the "are we there yet ?" is much slower given that a long Sleep() is common in that option. But the example I posted is GUIOnEventMode=0. It does use GUIGetMsg() to handle messages and CPU usage so, why not have the trigger right there. So that's what I added in this version. And obviously responds much faster than scheduling an Adlib. Edit: ..and this is v2.1.1 ( child proofing ? ) I was thinking that it would be nice to tell, the new to this UDF, that a set of choices would not work ( not as extreme as in MsgBox_Extn() but, something ). Also to run ControlViewer just in case of an "oops". where you can select a script, press DEL, and process close it, if something went wrong. ( and I use it a lot ) So there: for all those that should be sleeping at 3 AM but want to code and screw up, because the brain is sleeping regardless of will.
    1 point
  6. MattyD

    AutoIt Snippets

    Hi all - here's a quick example of how you can "hit test" controls under the mouse. You can't directly handle WM_NCHITTEST with GuiRegisterMessage() - controls don't pass this message on to the parent. We can directly grab messages from a control however, as long as we send them to the old handler when we're done. Note: for buttons I *think* you can use WM_MOUSEHOVER via a traditional GUIRegisterMessage, which is obviously a better option - but this will work with labels etc... Edit: oops I guess I was a little too hasty here! - this looks to brake stuff. I'll update the post if I find a solution... Fixed!! #include <guiConstants.au3> #include <winapi.au3> Global $hGui = GUICreate("", 200, 100) Global $hBtn = GUICtrlCreateButton("Test", 4, 4, 80, 80) Global $hBtnProc = DllCallbackRegister("ButtonProc", "long", "hwnd;uint;wparam;lparam") Global $pOrigBtnProc = _WinAPI_GetWindowLong(GUICtrlGetHandle($hBtn), $GWL_WNDPROC) _WinAPI_SetWindowLong(GUICtrlGetHandle($hBtn), $GWL_WNDPROC, DllCallbackGetPtr($hBtnProc)) GUISetState() while 1 $Msg = GUIGetMsg(1) Switch $Msg[0] Case $GUI_EVENT_CLOSE Exit Case $hBtn ConsoleWrite("Clicked" & @CRLF) EndSwitch wend Func ButtonProc($hWnd, $uMsg, $wParam, $lParam) Switch $uMsg Case $WM_NCHITTEST ConsoleWrite(StringFormat("Button Hit. Mouse:[%d,%d]\r\n", BitAND($lParam, 0xFFFF), BitShift($lParam, 16))) EndSwitch Local $aRet = DllCallAddress("long", $pOrigBtnProc, "hwnd", $hWnd, "uint", $uMsg, "wparam", $wParam, "lparam", $lParam) Return $aRet[0] EndFunc
    1 point
  7. It's been a long time since I wrote this, I know. But, time for an update. Read all about this v2.1 up on the first post.
    1 point
  8. I think you should create separate profile for yours automation, I mean not using the main chrome profile directory.
    1 point
  9. 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
  10. Version 1.6.3.0 of the UDF has been released. Please test before using in production! For download please see my signature.
    1 point
  11. I was in need of an IPC (Interprocess communication) between system, admin and user levels, and ended up writing this UDF to suit my wantings. Hope you find it useful too. Works from WinXP/Server2003 to the now current Win10/Server2016. It communicates between any mix of x32, x64, Admin, User. In the zip file, there is the UDF and an example: FMIPC(v0.2018.04.04).zip Special thanks to @RTFC for the help in the support forum
    1 point
  12. I have encountered some issues with using AutoIt on a work VM to do some Send and MouseClick while my RDP session was disconnected. The main problem is that when you do not have a monitor connected, or a RDP session, you do not have a... resolution? There's is no desktop 'window', things sort of stop existing in the same context as when you have a monitor or RDP session connected. I don't have a good way to describe it. Anyways, my solution to this to allow things to still process and work while I wasn't connected to the RDP myself, was to connect the VM to itself through RDP. Yeah, it's weird, and I haven't automated having it connect to itself when no one else is connected. But before I turn off my computer I start a new RDP session on the VM to the VM, which then disconnects my RDP session because someone else (the VM itself) connected. Since it's connected and the RDP connection is able to create a virtual desktop/monitor/resolution, things like MouseClick, Send, and I assume everything else work.
    1 point
×
×
  • Create New...