Jump to content

ITaskBarList UDF - Rewrite for Beta All Methods Included


Beege
 Share

Recommended Posts

Last Update 10/1/11

This is a rewrite of my previous thumbnail toolbar UDF that includes all the other methods for ITaskBarList4. Some of the function new functions I really liked were the icon overlays like the IE icon in the snapshot, and SetThumbNailClip that allows you to crop the Thumbnail preview to any portion of the gui you want it to be. I tested this in 64bit and didnt have any problems so hopefully all the structure alignment problems have been fixed in autoit. As with anything I post, please let me know if you have any problems or suggestions (and I love comments). Requirements are Windows 7 and the new beta (3.3.7.18). All examples are included in the attatchment.

Special thanks to the AutoitObject Team, wraithdu for his original ITaskBarList Example, and extra thanks to trancexx for the new ObjCreateInterface() thats actually included in autoit now!! Your the F****ing Sh**t! :mellow:

SnapShot.PNG

UDF Functions

; #INDEX# =======================================================================================================================
; Title .........: ITaskBarList
; AutoIt Version : 3.3.7.18 (Beta)
; Language ......: English
; Description ...: Functions to assist in using the ITaskBarList Interface.
; Author(s) .....: Brian J Christy (Beege)
; ===============================================================================================================================
 
; #CURRENT# =====================================================================================================================
; _ITaskBar_CreateTaskBarObj - Creates a ITaskBarList object.
; _ITaskBar_SetOverlayIcon - Applies an overlay to a taskbar button to indicate application status or a notification to the user.
; _ITaskBar_SetThumbNailClip - Selects a portion of a window's client area to display as that window's thumbnail in the taskbar.
; _ITaskBar_AddTBButtons - Applies buttons that have been previously created using _ITaskBar_CreateTBButton()
; _ITaskBar_CreateTBButton - Creates a ThumbBar button
; _ITaskBar_UpdateTBButton - Shows, enables, disables, or hides buttons in a thumbnail toolbar as required by the window's current state.
; _ITaskBar_SetTBImageList - Specifies an image list that contains button images for a toolbar embedded in a thumbnail image of a window in a taskbar button flyout.
; _ITaskBar_ActivateTab - Activates an item on the taskbar. The window is not actually activated; the window's item on the taskbar is merely displayed as active.
; _ITaskBar_AddTab - Adds an item to the taskbar.
; _ITaskBar_DeleteTab - Deletes an item from the taskbar.
; _ITaskBar_SetActiveAlt - Marks a taskbar item as active but does not visually activate it.
; _ITaskBar_MarkFullscreenWindow - Marks a window as full-screen.
; _ITaskBar_RegisterTab - Informs the taskbar that a new tab or document thumbnail has been provided for display in an application's taskbar group flyout.
; _ITaskBar_UnregisterTab - Removes a thumbnail from an application's preview group when that tab or document is closed in the application.
; _ITaskBar_SetTabProperties - Allows a tab to specify whether the main application frame window or the tab window should be used as a thumbnail or in the peek feature under certain circumstances.
; _ITaskBar_SetProgressState - Sets the type and state of the progress indicator displayed on a taskbar button.
; _ITaskBar_SetProgressValue - Displays or updates a progress bar hosted in a taskbar button to show the specific percentage completed of the full operation.
; _ITaskBar_SetTabActive - Informs the taskbar that a tab or document window has been made the active window.
; _ITaskBar_SetTabOrder - Inserts a new thumbnail into a tabbed-document interface (TDI) or multiple-document interface (MDI) application's group flyout or moves an existing thumbnail to a new position in the application's group.
; _ITaskBar_SetThumbNailToolTip - 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.
; _ITaskBar_DestroyObject - Destroys ITaskBarObject and icons freeing any memory the icons occupied
; ===============================================================================================================================

Example 1

Spoiler
#include <ITaskBarList.au3>
#include <ButtonConstants.au3>
 
$GUI = GUICreate("Thumbnail Button", 250, 100)
GUICtrlCreateButton('ThumbNailClip', 1, 1)
GUISetState(@SW_SHOW)
 
$oTaskbar = _ITaskBar_CreateTaskBarObj()
$but1 = _ITaskBar_CreateTBButton('Down ToolTip', @ScriptDir & 'IconsDown.ico', -1, '_Down_Button')
$but2 = _ITaskBar_CreateTBButton('Left ToolTip', @ScriptDir & 'IconsLeft.ico', -1, '_Left_Button')
$but3 = _ITaskBar_CreateTBButton('', @ScriptDir & 'IconsLeft.ico', -1, '_Right_Button');no tooltip
$but4 = _ITaskBar_CreateTBButton('Internet Explorer',@ProgramFilesDir & 'Internet Exploreriexplore.exe', -1, '_IE_Button');
$but5 = _ITaskBar_CreateTBButton('AutoIt', @AutoItExe, -1, '_AutoIt_Button');
_ITaskBar_AddTBButtons($GUI)
 
_ITaskBar_SetThumbNailToolTip($GUI, 'ITaskBarList UDF ToolTip Example')
 
; Set progressbar to normal state (green)
_ITaskBar_SetProgressState($GUI, 2)
For $i = 1 to 100
_ITaskBar_SetProgressValue($GUI, $i)
Sleep(75)
; Set progressbar to Paused state (yellow). Notice that even thought the progressbar is in "paused" state, you can
; still can change the value. Its just an indicator. It doesnt actually pause anything.
If $i = 25 Then _ITaskBar_SetProgressState($GUI, 8);
;Set progressbar to Error state (red). This works the same way as paused state. Its just an indicator.
If $i = 50 Then _ITaskBar_SetProgressState($GUI, 4)
;Set progressbar back to normal state (green)
If $i = 75 Then _ITaskBar_SetProgressState($GUI, 2)
Next
 
;set progressbar Indeterminate
_ITaskBar_SetProgressState($GUI, 1)
Sleep(3000)
;clear progressbar
_ITaskBar_SetProgressState($GUI)
 
;Set ThumbNail Preview to only show the button from the GUI
MsgBox(0,'SetThumbNailClip','Notice that the ThumbNail preview shows the whole GUI.', 30, $Gui)
_ITaskBar_SetThumbNailClip($GUI, 0, 0, 80, 30)
MsgBox(0,'SetThumbNailClip','Now look again. You should only see the ThumbNailClip Button', 30, $Gui)
; clear thumbnail clip
_ITaskBar_SetThumbNailClip($GUI)
 
;Add Icon Overlay
_ITaskBar_SetOverlayIcon($GUI, @ProgramFilesDir & 'Internet Exploreriexplore.exe')
MsgBox(0,'SetOverlayIcon','Taskbar tab should have and Internet Explorer icon overlay. ', 30, $Gui)
; clear icon overlay
_ITaskBar_SetOverlayIcon($GUI)
 
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
 
Func _Down_Button()
MsgBox(0, 'Button Pressed', 'Down Button has been Pressed.')
EndFunc   ;==>_Down_Button
 
Func _Left_Button()
MsgBox(0, 'Button Pressed', 'Left Button has been Pressed.')
EndFunc   ;==>_Left_Button
 
Func _Right_Button()
MsgBox(0, 'Button Pressed', 'Right Button has been Pressed.')
EndFunc   ;==>_Right_Button
 
Func _IE_Button()
MsgBox(0, 'Button Pressed', 'IE Button has been Pressed.')
EndFunc
 
Func _AutoIt_Button()
MsgBox(0, 'Button Pressed', 'AutoIT Button has been Pressed.')
EndFunc

Example 2

Spoiler
#region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_UseX64=n
#endregion ;**** Directives created by AutoIt3Wrapper_GUI ****
#region Header
 
#include <ITaskBarList.au3>
#include <ButtonConstants.au3>
#include <GuiImageList.au3>
#include <StaticConstants.au3>
 
$hGUI = GUICreate("ThumbBar", 253, 140)
$cbEnabled = GUICtrlCreateCheckbox("Enabled", 33, 48, 73, 19)
$cbHidden = GUICtrlCreateCheckbox("Hidden", 33, 78, 73, 19)
$cbBackground = GUICtrlCreateCheckbox("No BackGround", 123, 48, 97, 19)
$cbDisabled = GUICtrlCreateCheckbox("Disabled", 33, 108, 73, 19)
$cbInteractive = GUICtrlCreateCheckbox("Non Interactive", 123, 78, 91, 19)
$cbDismission = GUICtrlCreateCheckbox("Dismission Click", 123, 108, 91, 19)
$Label1 = GUICtrlCreateLabel("Button Flags", 72, 12, 108, 28)
GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif")
GUICtrlSetState($cbEnabled, $GUI_CHECKED)
GUICtrlSetState($cbEnabled, $GUI_DISABLE)
GUIRegisterMsg($WM_COMMAND, '_MY_WM_COMMAND')
GUISetState(@SW_SHOW)
 
_ITaskBar_CreateTaskBarObj()
 
$Wow64 = ""
If @AutoItX64 Then $Wow64 = "Wow6432Node"
$sPath = RegRead("HKEY_LOCAL_MACHINESOFTWARE" & $Wow64 & "AutoIt v3AutoIt", "InstallDir") & "ExamplesGUIAdvancedImages"
 
$hImageList = _GUIImageList_Create()
_GUIImageList_AddBitmap($hImageList, $sPath & "Green.bmp")
_GUIImageList_AddBitmap($hImageList, $sPath & "Blue.bmp")
_ITaskBar_SetTBImageList($hGUI, $hImageList)
 
$but1 = _ITaskBar_CreateTBButton('IE', @ProgramFilesDir & 'Internet Exploreriexplore.exe')
$but2 = _ITaskBar_CreateTBButton('Left ToolTip', @ScriptDir & 'IconsLeft.ico')
$but3 = _ITaskBar_CreateTBButton('Right ToolTip', @ScriptDir & 'IconsRight.ico')
$but4 = _ITaskBar_CreateTBButton('Green', -1, 0)
$but5 = _ITaskBar_CreateTBButton('Blue', -1, 1)
$but6 = _ITaskBar_CreateTBButton('AutoIt', @AutoItExe);
_ITaskBar_AddTBButtons($hGUI)
 
_ITaskBar_SetOverlayIcon($hGUI, @ProgramFilesDir & 'Internet Exploreriexplore.exe')
 
While 1
Switch GUIGetMsg()
Case $cbHidden, $cbEnabled, $cbBackground, $cbDisabled, $cbInteractive, $cbDismission
Global $iFlags = $THBF_ENABLED
If BitAND(GUICtrlRead($cbHidden), $GUI_CHECKED) Then $iFlags += $THBF_HIDDEN
If BitAND(GUICtrlRead($cbBackground), $GUI_CHECKED) Then $iFlags = BitOR($iFlags, $THBF_NOBACKGROUND)
If BitAND(GUICtrlRead($cbDisabled), $GUI_CHECKED) Then $iFlags = BitOR($iFlags, $THBF_DISABLED)
If BitAND(GUICtrlRead($cbInteractive), $GUI_CHECKED) Then $iFlags = BitOR($iFlags, $THBF_NONINTERACTIVE)
If BitAND(GUICtrlRead($cbDismission), $GUI_CHECKED) Then $iFlags = BitOR($iFlags, $THBF_DISMISSonclick)
For $i = $but1 To $but6;set all buttons the same flag
_ITaskBar_UpdateTBButton($i, $iFlags)
If @error Then ConsoleWrite(_Get_HRESULT_ERROR_STRING(@error) & @CRLF)
Next
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
WEnd
 
Func _MY_WM_COMMAND($hWnd, $msg, $wParam, $lParam)
 
Local $iMsg = _WinAPI_HiWord($wParam)
 
If $iMsg = $THBN_CLICKED Then
Local $iID = _WinAPI_LoWord($wParam)
Switch $iID
Case $but1
ConsoleWrite('IE Button has been Pressed.' & @CRLF)
Case $but2
ConsoleWrite('Left Button has been Pressed.' & @CRLF)
Case $but3
ConsoleWrite('Right Button has been Pressed.' & @CRLF)
Case $but4
ConsoleWrite('Green Button has been Pressed.' & @CRLF)
Case $but5
ConsoleWrite('Blue Button has been Pressed.' & @CRLF)
Case $but6
ConsoleWrite('Autoit Button has been Pressed.' & @CRLF)
EndSwitch
EndIf
 
Return $GUI_RUNDEFMSG
 
EndFunc   ;==>_MY_WM_COMMAND

ITaskBarList.zip

Edited by Beege
Link to comment
Share on other sites

Great job! Glad you turned it into a UDF too. Could you make it so the picture on the button can be the icon from a specified .exe? I'd been trying to make that possible and couldn't ever get it. Thanks.

For those who are asking questions, look in the help file first. I'm tired of people asking stupid questions about how to do things when 10 seconds in the help file could solve their problem.[quote name='JRowe' date='24 January 2010 - 05:58 PM' timestamp='1264381100' post='766337'][quote name='beerman' date='24 January 2010 - 03:28 PM' timestamp='1264372082' post='766300']They already have a punishment system for abuse.[/quote]... and his his name is Valik.[/quote]www.minikori.com

Link to comment
Share on other sites

Great job! Glad you turned it into a UDF too. Could you make it so the picture on the button can be the icon from a specified .exe? I'd been trying to make that possible and couldn't ever get it. Thanks.

Thanks Minikori. Your question helped me spot a bug in my code so be sure to get the updated UDF before using the example I set up for you. :mellow:

#include <ThumbBar.au3>
#include <ButtonConstants.au3>

$GUI = GUICreate("Thumbnail Button", 250, 10)
GUISetState(@SW_SHOW)

$AutoIt_Icon = _GetEXEIcon(@AutoItExe)
$IE_Icon = _GetEXEIcon(@ProgramFilesDir & '\Internet Explorer\iexplore.exe')

$but1 = _ThumbBar_CreateButton('AutoIt Icon', $AutoIt_Icon, -1, '_Autoit')
$but2 = _ThumbBar_CreateButton('IE Icon', $IE_Icon, -1, '_IE')
_ThumbBar_AddButtons($Gui)

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE

Func _Autoit()
    MsgBox(0,'Button Pressed', 'Autoit Button has been Pressed.')
EndFunc
Func _IE()
    MsgBox(0,'Button Pressed', 'IE Button has been Pressed.')
EndFunc

Func _GetEXEIcon($sPath)
    Local $Icon = DllStructCreate("handle")
    $iIcon = _WinAPI_ExtractIconEx($sPath, 0, 0, DllStructGetPtr($Icon), 1)
    If @error Then Return SetError(1, 0, 0)
    Return DllStructGetData($Icon,1)
EndFunc
Link to comment
Share on other sites

Thanks! This helped me a lot.

For those who are asking questions, look in the help file first. I'm tired of people asking stupid questions about how to do things when 10 seconds in the help file could solve their problem.[quote name='JRowe' date='24 January 2010 - 05:58 PM' timestamp='1264381100' post='766337'][quote name='beerman' date='24 January 2010 - 03:28 PM' timestamp='1264372082' post='766300']They already have a punishment system for abuse.[/quote]... and his his name is Valik.[/quote]www.minikori.com

Link to comment
Share on other sites

1, i use the first Example 1.

when i hide the gui(WinSetState($GUI,"",@SW_HIDE)),and then show itWinSetState($GUI,"",@SW_SHOW) ,the Thumbnail Toolbar disappeared.

2, use the udf in my program, the console show

"! COM Error ! Number: 0x00000002 ScriptLine: 3748 - Can't install a new Errorhandler when one is still active." my error.

Edited by gooker
Link to comment
Share on other sites

1, i use the first Example 1.

when i hide the gui(WinSetState($GUI,"",@SW_HIDE)),and then show itWinSetState($GUI,"",@SW_SHOW) ,the Thumbnail Toolbar disappeared.

Its because its a new tab has been created. Same thing will happen if you use methods DeleteTab and AddTab. You must call _ThumbBar_AddButtons($GUI) after being restored. ex:

GUISetState(@SW_HIDE)
sleep(3000)
GUISetState(@SW_SHOW)
_ThumbBar_AddButtons($GUI)
Link to comment
Share on other sites

I installed win 7 x64 yesterday since I'm on new machine. One of first things I wanted to do is test these new things this system offers. It's nice, I must say.

Why am I posting this? There is a bug with AutoIt an DllStructCreate() function. It's causing (or could be) your udf not to work properly on x64. Why no one said that I guess it's a mystery. Beege, do you have x64 win 7? I see you use some code that involves checking for that. Are examples working on x64 AutoIt for you?

Anyway, considering how you construct $tagTHUMBBUTTON and access created structure afterwards you should declare $tagTHUMBBUTTON like this:

$tagTHUMBBUTTON = "dword;dword;dword;handle;WCHAR[260];dword_ptr"

Otherwise I don't see how could this udf work with both 32bit or 64bit AutoIt.

You correct - I rate.

♡♡♡

.

eMyvnE

Link to comment
Share on other sites

I installed win 7 x64 yesterday since I'm on new machine. One of first things I wanted to do is test these new things this system offers. It's nice, I must say.

Does that mean I'm finally off the hook as your 64-bit bitch? :mellow:

Broken link? PM me and I'll send you the file!

Link to comment
Share on other sites

@trancexx, Sorry for the delay. Don't know how I missed that there was a new post. I am running 32bit. The 64bit checking was from an example in help file from one of the _guiimagelist functions. Did the examples fail for you? If so then just like you said, why the hell didnt anyone say something? There have been like 80+ downloads. :(

Anyway thanks for the fix. (it did fix it right?). I will make the changes tonight.

Edited by Beege
Link to comment
Share on other sites

Funny it didn't work on your machine, trancexx, I'm running x64 Windows 7 Ultimate and this has worked the entire time :(

For those who are asking questions, look in the help file first. I'm tired of people asking stupid questions about how to do things when 10 seconds in the help file could solve their problem.[quote name='JRowe' date='24 January 2010 - 05:58 PM' timestamp='1264381100' post='766337'][quote name='beerman' date='24 January 2010 - 03:28 PM' timestamp='1264372082' post='766300']They already have a punishment system for abuse.[/quote]... and his his name is Valik.[/quote]www.minikori.com

Link to comment
Share on other sites

Funny it didn't work on your machine, trancexx, I'm running x64 Windows 7 Ultimate and this has worked the entire time :(

Hmmm, Thats intresting. I have been telling myself this didn't make much sense. That dword only stores conbination of THUMBBUTTONFLAGS:
typedef enum THUMBBUTTONFLAGS {
    THBF_ENABLED = 0x00000000,
    THBF_DISABLED = 0x00000001,
    THBF_DISMISSonclick = 0x00000002,
    THBF_NOBACKGROUND = 0x00000004,
    THBF_HIDDEN = 0x00000008,
    THBF_NONINTERACTIVE = 0x00000010
} THUMBBUTTONFLAGS;

That should only be a max value of 32 and a dword is plenty big enough to hold that. :) What version autoit are you using Minikori?

Link to comment
Share on other sites

Its interesting that its working on some 64bit computers and not others. I also assumed that when you tell me I should declare the $tagTHUMBBUTTON structure different, that the problem is coming from the structure. Are you fucking with me or something? What exactly is the problem on x64? :(

Link to comment
Share on other sites

Its interesting that its working on some 64bit computers and not others.

It works on all x64 computers. It's not working on x64 computers.

Both is true.

I also assumed that when you tell me I should declare the $tagTHUMBBUTTON structure different, that the problem is coming from the structure. Are you fucking with me or something? What exactly is the problem on x64? :(

Structure will be unaligned on x64 AutoIt. And there is no way of fixing that. There is no syntax.

Thing is when some bigger structures is made of smaller structures

BigStructure = SmallStructure1;SmallStructure2;SmallStructure3;
every structure for itself must be properly aligned.

Since align keyword can be used only at the beginning of structure tags AutoIt will mess things up in your case.

To go around the problem you must add another member at the end of every structure that you make for x64 AutoIt. But you can't because you are accessing elements by their ordinal values. You can on the other hand do dword[2], but that's more confusing and requires more work.

It's not important what system is run on. It's important what AutoIt is run on.

♡♡♡

.

eMyvnE

Link to comment
Share on other sites

Thanks for the explanation, but I'm still left wondering if changing the dword to a dword_ptr fixed it. :(

Structure will be unaligned on x64 AutoIt. And there is no way of fixing that.

Is this some kind of a bug?

It's not important what system is run on. It's important what AutoIt is run on.

This is why I wanted to know what version Minikori was using..
Link to comment
Share on other sites

According to help file:

If a change of alignment is needed "align" can be use before the first element which need to be changed.

So I think you can use the 'align' keyword before any member.

I've run into this problem before with the _GUICtrlListView_Create example. The definition of $tagNMLVKEYDOWN is:

Global Const $tagNMLVKEYDOWN = $tagNMHDR & ";align 1;word VKey;uint Flags"

This still somehow messes up the alignment on x64. You have to add a 32-bit member to the end of $tagNMHDR as padding when run under x64 (dword, int, whatever). I'd be interested to know how the C compilers handle this structure alignment.

In this case, the 'align' keyword cannot fix this problem.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...