[class][v1/v2] taskbar ornaments and controls

Post your working scripts, libraries and tools for AHK v1.1 and older
Helgef
Posts: 4709
Joined: 17 Jul 2016, 01:02
Contact:

[class][v1/v2] taskbar ornaments and controls

02 Aug 2017, 09:01

Introduction
This class implements some of the taskbar extensions discussed here (msdn).
For a full introduction and documentation, please visit the github wiki.
There are two versions available, one for (recent) AHK v1.1 and one for AHK v2 (2.0-a081-cad307c). The version for v2 is cleverly named taskbarInterface_v2.ahk

Graphical preview - a selection
Image
Button controls in the thumbnail preview window, the thumbnail preview is clipped to only show a listbox of the gui.
Image
Progress bar and icon overlay.

Download
Source and self-contained examples are available at github. Direct download: v1.02_with_examples.rar.
Mini tutorial
To highlight the ease of use. I give a mini tutorial.

Part 1 - show an icon overlay.
Image
Code

Part 2 - show a progress bar behind the taskbar icon.
Image
Code

Part 3 - Add two buttons to the thumbnail preview.
Image
Code
Real use example
Please try out wolf_II's nice app Anagrams (v2.13+), for a real use example of this class.

Misc
Feel free to use this in whichever modified or non-modified state you wish, for any peaceful purpose. No credits or references needed.

Have fun and good luck :wave:
Last edited by Helgef on 13 Aug 2017, 03:37, edited 3 times in total.
User avatar
TheDewd
Posts: 1507
Joined: 19 Dec 2013, 11:16
Location: USA

Re: [class][v1/v2] taskbar ornaments and controls

02 Aug 2017, 09:46

This is crazy good! Thanks for sharing! Does it work with Windows 10?
Helgef
Posts: 4709
Joined: 17 Jul 2016, 01:02
Contact:

Re: [class][v1/v2] taskbar ornaments and controls

02 Aug 2017, 09:55

Thanks. I have tested it only briefly on win 10 and saw no problems. All development is done on win7 though. However, I have seen nothing in the documentation of the used apis, suggesting there would be any compabillity issues with win10.
Last edited by Helgef on 03 Aug 2017, 02:36, edited 1 time in total.
wolf_II
Posts: 2688
Joined: 08 Feb 2015, 20:55

Re: [class][v1/v2] taskbar ornaments and controls

02 Aug 2017, 15:55

Thank you for sharing this class. I really love it. :clap: :thumbup:

I have posted an update to Anagrams that includes credit and link to here.
User avatar
Delta Pythagorean
Posts: 627
Joined: 13 Feb 2017, 13:44
Location: Somewhere in the US
Contact:

Re: [class][v1/v2] taskbar ornaments and controls

02 Aug 2017, 18:35

This is actually quite impressive! I think I'll implement this into some of my programs for later use!

[AHK]......: v2.0.12 | 64-bit
[OS].......: Windows 11 | 23H2 (OS Build: 22621.3296)
[GITHUB]...: github.com/DelPyth
[PAYPAL]...: paypal.me/DelPyth
[DISCORD]..: tophatcat

User avatar
joedf
Posts: 8940
Joined: 29 Sep 2013, 17:08
Location: Canada
Contact:

Re: [class][v1/v2] taskbar ornaments and controls

02 Aug 2017, 21:57

Holy moly, nice! :D
Image Image Image Image Image
Windows 10 x64 Professional, Intel i5-8500, NVIDIA GTX 1060 6GB, 2x16GB Kingston FURY Beast - DDR4 3200 MHz | [About Me] | [About the AHK Foundation] | [Courses on AutoHotkey]
[ASPDM - StdLib Distribution] | [Qonsole - Quake-like console emulator] | [LibCon - Autohotkey Console Library]
Helgef
Posts: 4709
Joined: 17 Jul 2016, 01:02
Contact:

Re: [class][v1/v2] taskbar ornaments and controls

03 Aug 2017, 03:58

Thanks for your kind words.

I have added a mini tutorial to the first post. To give a quick insight on how to use this.

Cheers.
User avatar
boiler
Posts: 16768
Joined: 21 Dec 2014, 02:44

Re: [class][v1/v2] taskbar ornaments and controls

03 Aug 2017, 09:23

Very nice work. Will be quite useful. Thank you for sharing this with us.
User avatar
gwarble
Posts: 524
Joined: 30 Sep 2013, 15:01

Re: [class][v1/v2] taskbar ornaments and controls

04 Aug 2017, 15:50

very nice, thanks for sharing
EitherMouse - Multiple mice, individual settings . . . . www.EitherMouse.com . . . . forum . . . .
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: [class][v1/v2] taskbar ornaments and controls

10 Aug 2017, 13:59

@Helgef: many thanks for this.

I would be interested to know if some of these methods can be applied to external taskbar buttons. The main problem is how to get a pointer to the interface. [EDIT:] This can be done simply by using ComObjCreate as shown in the DllCall example below.

[EDIT:] These links were useful, especially the DllCall one:
[advanced] Using raw COM interfaces in AHK - Tutorials - AutoHotkey Community
https://autohotkey.com/board/topic/8107 ... es-in-ahk/
[AHK_L + AHK v2] COM Classes Framework (CCF) - Scripts and Functions - AutoHotkey Community
https://autohotkey.com/board/topic/6620 ... ework-ccf/
interfaces · maul-esel/COM-Classes Wiki · GitHub
https://github.com/maul-esel/COM-Classe ... interfaces
GitHub - maul-esel/COM-Classes: AHK classes that implement COM interfaces
https://github.com/maul-esel/COM-Classes
[the final example here relates to taskbar buttons:]
DllCall
https://autohotkey.com/docs/commands/DllCall.htm

[EDIT:] After reading up on everything, I wrote an example that shows how to change the colour of taskbar buttons for any window (red/yellow/green):
Distinguishing Between Multiple Windows of Same Application - AutoHotkey Community
https://autohotkey.com/boards/viewtopic ... 88#p164288

==================================================

To create the object and to make the taskbar button change colour like a progress bar see the 'initInterface' and 'setProgress' functions:
taskbarInterface/taskbarInterface.ahk at master · HelgeffegleH/taskbarInterface · GitHub
https://github.com/HelgeffegleH/taskbar ... erface.ahk

Also see:
ITaskbarList interface (Windows)
https://msdn.microsoft.com/en-us/librar ... s.85).aspx
ITaskbarList3 interface (Windows)
https://msdn.microsoft.com/en-us/librar ... s.85).aspx
Last edited by jeeswg on 10 Aug 2017, 16:48, edited 2 times in total.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
Helgef
Posts: 4709
Joined: 17 Jul 2016, 01:02
Contact:

Re: [class][v1/v2] taskbar ornaments and controls

10 Aug 2017, 16:15

@boiler and gwarble, cheers!
Hello jeeswg :wave:
Regarding applying to external taskbar buttons, I assume you mean buttons belonging to windows not owned by your application. I did write in the documentation that the window must belong to the application, I took that from memory :D I'm somewhat certain I read it somewhere. Your example suggests that at least the progress method can be applied to unowned windows, nice! But keep in mind, whenever the button is destroyed, eg when the window is hidden and then shown again, you need to re-apply the progess. My implementation handles that, but not for windows which doesn't belong to the script.
The main problem is how to get a pointer to the interface.
I'm not certain what you mean.

Cheers.
User avatar
rommmcek
Posts: 1470
Joined: 15 Aug 2014, 15:18

Re: [class][v1/v2] taskbar ornaments and controls

12 Aug 2017, 10:07

Very impressive! Helgef for Administrator!
Btw: Showing Icon image in the thumbnail seems to be Dpi depended. I'm using Gui, new, hwndhWnd -DPIScale.
Attachments
Dpi dependencies.png
Dpi dependencies.png (16.81 KiB) Viewed 6444 times
Helgef
Posts: 4709
Joined: 17 Jul 2016, 01:02
Contact:

Re: [class][v1/v2] taskbar ornaments and controls

13 Aug 2017, 03:34

Hello rommmcek.
Good observeration! In a non-example context, one should probably not hardcode the clip coordinates, but rather scale them using A_ScreenDPI, or as you suggest, use -DPIScale. I made a note in the documentation.
@ jeeswg. I saw your edit, which relates to my uncertainty. Note that the when I use the word interface I mean the explicit graphical connection link between the user and the taskbar. taskbarInterface.ahk is not an implementation of the ITaskbarList abstract (data type / class template) interface, it is (partly) a wrapper around window's implementation of that abstract interface.
From your link, ITaskbarList3
Remarks wrote: When to Implement
An implementation of this interface is provided in Windows as CLSID_TaskbarList. This interface is not implemented by third parties.
Cheers.
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: [class][v1/v2] taskbar ornaments and controls

15 Aug 2017, 23:55

I was interested in whether ITaskbarList/2/3/4 could be used to list all the windows with taskbar buttons. AFAIK there is not a method to do this.

I had hoped that if you tried some of the ITaskbarList/ITaskbarList3 methods using hWnds (e.g. all visible windows retrieved via WinGet) that did/didn't have a taskbar button, the return value, success/failure, would give you a way to determine which hWnds had taskbar buttons and which didn't. Unfortunately the methods I tested appeared to return 0 every time, whether the window had a taskbar button or not.

Anyhow, I mention this in case I missed something, and the approach could be made to work somehow, or if anyone has an alternative approach other than checking window styles/extended styles. Cheers.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
Helgef
Posts: 4709
Joined: 17 Jul 2016, 01:02
Contact:

Re: [class][v1/v2] taskbar ornaments and controls

17 Aug 2017, 13:02

jeeswg, you could check if the functions set A_LastError on failure, I do not remember.
if anyone has an alternative approach other than checking window styles/extended styles
Can you do it by style?

Cheers.
Edit:
jeeswg wrote:qwerty12 wrote a function for listing taskbar buttons:
Nice :thumbup:
Although, a bit off topic ;)
Edit-cheers!
Last edited by Helgef on 27 Aug 2017, 07:01, edited 1 time in total.
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: [class][v1/v2] taskbar ornaments and controls

17 Aug 2017, 13:42

Thanks Helgef, A_LastError is a good suggestion but it didn't appear to work.

I've tried adding/removing a tab, and getting the window style/ExStyle before/after, (see the code,) but it didn't show any difference.

I've posted my code, in case I've missed something:

Code: Select all

;useful example at the bottom of:
;DllCall
;https://autohotkey.com/docs/commands/DllCall.htm

;it appears that the return value is always 0, so we don't have info re. identifying which windows have a taskbar button
q:: ;try to set taskbar value, if it fails then check for an error message that would indicate that the window doesn't have a taskbar button
IID_ITaskbarList := "{56FDF342-FD6D-11d0-958A-006097C9A090}"
IID_ITaskbarList3 := "{EA1AFB91-9E28-4B86-90E9-9E9F8A5EEFAF}"
CLSID_TaskbarList := "{56FDF344-FD6D-11d0-958A-006097C9A090}"
;itbl := ComObjCreate(CLSID_TaskbarList, IID_ITaskbarList)
itbl := ComObjCreate(CLSID_TaskbarList, IID_ITaskbarList3)

DetectHiddenWindows, Off
WinGet, vWinList, List
DetectHiddenWindows, On
DllCall(vtable(itbl,3), Ptr,itbl) ;HrInit
Loop, % vWinList
{
	hWnd := vWinList%A_Index%
	WinGetTitle, vWinTitle, % "ahk_id " hWnd
	if (vWinTitle = "Untitled - Notepad")
	{
		WinGet, vWinStyle1, Style, % "ahk_id " hWnd
		WinGet, vWinExStyle1, ExStyle, % "ahk_id " hWnd
		DllCall(vtable(itbl,5), Ptr,itbl, Ptr,hWnd) ;DeleteTab
		WinGet, vWinStyle2, Style, % "ahk_id " hWnd
		WinGet, vWinExStyle2, ExStyle, % "ahk_id " hWnd
		DllCall(vtable(itbl,4), Ptr,itbl, Ptr,hWnd) ;AddTab
		WinGet, vWinStyle3, Style, % "ahk_id " hWnd
		WinGet, vWinExStyle3, ExStyle, % "ahk_id " hWnd
		MsgBox, % vWinStyle1 " " vWinExStyle1 "`r`n" vWinStyle2 " " vWinExStyle2 "`r`n" vWinStyle3 " " vWinExStyle3
	}

	DllCall("kernel32\SetLastError", UInt,12345) ;12345 is a 'random' number
	vRet := DllCall(vtable(itbl,9), Ptr,itbl, Ptr,hWnd, Int64,100, Int64,100) ;SetProgressValue
	;vRet := DllCall(vtable(itbl,10), Ptr,itbl, Ptr,hWnd, UInt,0) ;SetProgressState
	;vRet := DllCall(vtable(itbl,5), Ptr,itbl, Ptr,hWnd) ;DeleteTab ;removes taskbar buttons but not alt+tab icons
	;vRet := DllCall(vtable(itbl,6), Ptr,itbl, Ptr,hWnd) ;ActivateTab
	;vRet := DllCall(vtable(itbl,7), Ptr,itbl, Ptr,hWnd) ;SetActiveAlt
	vLastError := A_LastError
	vOutput .= hWnd "|" vRet "|" vLastError "|" vWinTitle "`r`n"
}
Clipboard := vOutput
MsgBox, % "done"
ObjRelease(itbl)
return

;==================================================

vtable(ptr, n) {
    ; NumGet(ptr+0) returns the address of the object's virtual function
    ; table (vtable for short). The remainder of the expression retrieves
    ; the address of the nth function's address from the vtable.
    return NumGet(NumGet(ptr+0), n*A_PtrSize)
}

;==================================================
[EDIT:] Btw I was curious as to whether some of the techniques in the script could be used to invoke (open) a specific Internet Explorer tab (or list the tabs, although listing the tabs can be done via COM).
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: [class][v1/v2] taskbar ornaments and controls

25 Aug 2017, 21:02

qwerty12 wrote a function for listing taskbar buttons:
Script to close all open windows - AutoHotkey Community
https://autohotkey.com/boards/viewtopic ... 53#p151753

Code: Select all

q:: ;list taskbar buttons
;[GetTaskbarVisibleWindows function]
;Script to close all open windows - AutoHotkey Community
;https://autohotkey.com/boards/viewtopic.php?f=5&t=32434&p=151753#p151753

DetectHiddenWindows, On
vOutput := ""
for _, hWnd in GetTaskbarVisibleWindows()
{
	WinGetTitle, vWinTitle, % "ahk_id " hWnd
	vOutput .= vWinTitle "`r`n"
}
MsgBox, % SubStr(vOutput, 1, -2)
return
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
zotune
Posts: 85
Joined: 17 Nov 2014, 17:57

Re: [class][v1/v2] taskbar ornaments and controls

27 Apr 2020, 08:37

Great script. Would it be possible to set overlay icons on external apps? That would be awesome.
Helgef
Posts: 4709
Joined: 17 Jul 2016, 01:02
Contact:

Re: [class][v1/v2] taskbar ornaments and controls

28 Apr 2020, 00:22

Thank you zotune :). The documentation says the application must own the window, so it is not supported. You can try though, I believe some features might work for unowned windows.

Cheers.

Return to “Scripts and Functions (v1)”

Who is online

Users browsing this forum: charlie89, gwarble and 130 guests