Advertisement
Lorenzo501

TaskbarList

Feb 8th, 2024 (edited)
797
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. https://www.autohotkey.com/docs/v2/lib/ComCall.htm#ExTaskbar
  2.  
  3. Class below was made by Nikola. I tried to get rid of the flashing orange taskbar icon w/ the example from the link above, but below you see useful activation ComCalls.
  4.  
  5. The difference between these two methods is that ActivateTab changes the appearance of the taskbar item to indicate that it is active, while SetActiveAlt does not.
  6. SetActiveAlt only marks the item as active internally, so that any user action that would activate a different tab in that process will activate the tab associated with hwnd instead
  7.  
  8. /**
  9.  * TaskbarList class
  10.  * @see {@link https://learn.microsoft.com/en-us/windows/win32/api/shobjidl_core/nn-shobjidl_core-itaskbarlist}
  11.  */
  12. class TaskbarList
  13. {
  14.       /**
  15.      * Interface Identifier (IID) of the TaskbarList class
  16.      * @type {string}
  17.      */
  18.     static IID := "{56FDF342-FD6D-11d0-958A-006097C9A090}"
  19.    
  20.       /**
  21.      * Class Identifier (CLSID) of the TaskbarList class
  22.      * @type {string}
  23.      */
  24.     static CLSID := "{56FDF344-FD6D-11d0-958A-006097C9A090}"
  25.  
  26.     /**
  27.      * Constructor for the TaskbarList class
  28.      */
  29.     __new()
  30.     {
  31.         /**
  32.          * COM object of the TaskbarList class
  33.          * @type {ComObject}
  34.          */
  35.         this.comobj := ComObject(TaskbarList.CLSID, TaskbarList.IID)
  36.        
  37.         /**
  38.          * Pointer to the COM object
  39.          * @type {ptr}
  40.          */
  41.         this.ptr    := this.comobj.ptr
  42.         this.__HrInit()
  43.     }
  44.    
  45.     /**
  46.      * Initializes the taskbar list object. This method must be called before any other ITaskbarList methods can be called.
  47.      * @param {hwnd} hwnd - Handle to the window
  48.      */
  49.     __HrInit()       => ComCall(3, this.comobj)
  50.    
  51.     /**
  52.      * Add a tab to the TaskbarList
  53.      * @param {hwnd} hwnd - Handle to the window
  54.      */
  55.     AddTab(hwnd)       => ComCall(4, this.comobj, "ptr", hwnd)
  56.    
  57.     /**
  58.      * Delete a tab from the TaskbarList
  59.      * @param {hwnd} hwnd - Handle to the window
  60.      */
  61.     DeleteTab(hwnd)    => ComCall(5, this.comobj, "ptr", hwnd)
  62.    
  63.     /**
  64.      * Activates an item on the taskbar. The window is not actually activated; the window's item on the taskbar is merely displayed as active.
  65.      * @param {hwnd} hwnd - Handle to the window
  66.      */
  67.     ActivateTab(hwnd)  => ComCall(6, this.comobj, "ptr", hwnd)
  68.    
  69.     /**
  70.      * Marks a taskbar item as active but does not visually activate it.
  71.      * @param {hwnd} hwnd - Handle to the window
  72.      */
  73.     SetActiveAlt(hwnd) => ComCall(7, this.comobj, "ptr", hwnd)
  74. }
Advertisement
Comments
Add Comment
Please, Sign In to add comment
Advertisement