Is there a way to put an icon outside the hidden tray icons by default?

Get help with using AutoHotkey and its commands and hotkeys
User avatar
JoeWinograd
Posts: 1608
Joined: 10 Feb 2014, 20:00

Re: Is there a way to put an icon outside the hidden tray icons by default?

30 Jun 2020, 16:24

teadrinker wrote:but on my Windows 10 2004 returns an error
Same here on my W10 v2004. The error 0x80070490 appeared in a tooltip near the mouse pointer and did not go away until a reboot.
gwarble
Posts: 457
Joined: 30 Sep 2013, 15:01

Re: Is there a way to put an icon outside the hidden tray icons by default?

30 Jun 2020, 23:01

JoeWinograd wrote:
30 Jun 2020, 16:04
I keep a keen eye out for this issue and don't recollect anything from this morning, although it's possible that I missed it...but I just checked all my emails from the group yesterday and today...no dice. Regards, Joe
very weird, I must have been looking at an old post thinking it was new, but I still can't find what I thought I saw in a search (maybe I'm just losing it!) anyway somehow my memory got sparked to revisit this thread, the interface is there i think its just a matter of handling the expanded exported functions list... I'm still trying to understand how this works

Callback handling...
https://gist.github.com/ysc3839/25e8ed113c4e975b6781c9759ed4ee87

Code: Select all

//Win7
 NotificationMgr<ITrayNotify> NotiMgr(pTrayNotify);
 hr = pTrayNotify->RegisterCallback(&NotiMgr);
 pTrayNotify->RegisterCallback(nullptr);

//Win8
 ULONG callback_id = 0;
 NotificationMgr<ITrayNotifyWin8> NotiMgr8(pTrayNotifyW8);
 hr = pTrayNotifyW8->RegisterCallback(&NotiMgr8, &callback_id);
 hr = pTrayNotifyW8->UnregisterCallback(&callback_id);
EitherMouse - Multiple mice, individual settings . . . . www.EitherMouse.com . . . . forum . . . .
User avatar
JoeWinograd
Posts: 1608
Joined: 10 Feb 2014, 20:00

Re: Is there a way to put an icon outside the hidden tray icons by default?

02 Jul 2020, 17:50

vondess wrote:Just drag the said script's tray icon from the system stray pop-up and put it on the task bar.
Hi vondess,
You're not understanding the issue on two fronts. First, we're looking for a programmatic solution, so having the user drag the icon is not what we want. Second, we're not talking about the taskbar...we're talking about the system tray and its two components...the main/primary notification area, which is technically called "Shell_TrayWnd", and the overflow/secondary notification area, which is technically called "NotifyIconOverflowWindow". What we're looking for is a programmatic method either to (1) move an icon from NotifyIconOverflowWindow to Shell_TrayWnd or (2) force Windows to create the icon in Shell_TrayWnd, not NotifyIconOverflowWindow. Regards, Joe
gwarble
Posts: 457
Joined: 30 Sep 2013, 15:01

Re: Is there a way to put an icon outside the hidden tray icons by default?

02 Jul 2020, 18:16

i think he is only mistaken on the fact that we want a programmatic solution

its common terminology to call the entire full width bar the "task bar" including the system tray, so it makes perfect sense when he says from the system stray pop-up and put it on the task bar that he means drag the icon to the always visible system tray and it will stay there...


but yes, we want to do it via the windows API, so no dragging, no moving icons manually from parent to parent, there is an "undocumented" winAPI method called iTrayNotify that is documented well on the web by those other than Microsoft... the oldest version from windows 7 works as designed, proven fully functional above by teadrinker/jeeswg. I will be the first to admit that Microsoft made a correct decision by making not publishing this functionality, as I HATE apps that I install that do this... but I don't see any reason it can't be optional for elective software, and in a corporate environment is where I really need it (i use the color of my tray icon to reflect different information so I can monitor things throughout the shop without touching)

so the only outstanding part of the scripted solution is to figure out the differences needed to make the newer Windows 8+ version, iTrayNotifyWindows8 function similarly... I documented the differences above as best I understand, but I believe the way the exported function list has changed needs to be addressed, including UnRegisterCallback and the extra parameter on the RegisterCB
EitherMouse - Multiple mice, individual settings . . . . www.EitherMouse.com . . . . forum . . . .
jadams
Posts: 58
Joined: 13 Mar 2020, 10:48

Re: Is there a way to put an icon outside the hidden tray icons by default?

13 Jul 2020, 14:56

I also really need this.

Thought I would share a link for a solution using powershell and GPO:

https://4sysops.com/archives/forcing-notification-area-icons-to-always-show-in-windows-7-or-windows-8/

Understanding that code well enough to convert it to autohotkey is well above my pay grade, but I thought somebody here might be able to use that to come up with a workable solution.

Really hoping somebody can come up with a working class.
teadrinker
Posts: 1856
Joined: 29 Mar 2015, 09:41
Contact:

Re: Is there a way to put an icon outside the hidden tray icons by default?

14 Jul 2020, 14:34

@jadams
Of course, I can translate this script to AHK. But there is one issue:
Micah Rowland wrote:So we have our script, but there’s one last wrinkle. The IconStreams registry value is read into memory by Explorer.exe when explorer loads and all changes to the notification area are stored in memory, then written to the registry on shutdown. This means that if we run our script, not only will we see no results right away, those results will be overwritten with the current settings when we restart the computer. Not good. It’s a simple fix though. We launch our script from a batch file and we execute taskkill /im explorer.exe /f then we execute our script, then we restart explorer.exe.
So, first you have to kill explorer.exe, then run the script, then restart the explorer. It's not a problem?
jadams
Posts: 58
Joined: 13 Mar 2020, 10:48

Re: Is there a way to put an icon outside the hidden tray icons by default?

26 Aug 2020, 14:46

Sorry for being so slow to reply... I missed this message.

I would be quite happy to accept restarting Explorer as part of the fix. If you can post working code, I'd be grateful :-) 
teadrinker
Posts: 1856
Joined: 29 Mar 2015, 09:41
Contact:

Re: Is there a way to put an icon outside the hidden tray icons by default?

28 Aug 2020, 18:43

@jadams
As I understood, this code changes existing register entries, but can't add new ones, so you can't use it for a new application.
gwarble
Posts: 457
Joined: 30 Sep 2013, 15:01

Re: Is there a way to put an icon outside the hidden tray icons by default?

27 Sep 2020, 11:55

note to self and interested parties, here are some references to digest to help understand what is needed to convert iTrayNotify (functioning on Win7 thanks to @teadrinker above) to iTrayNotifyWin8 with these changes, id passed as second param to registercallback, new unregistercallback method using that id, new DoAction

Code: Select all

HRESULT RegisterCallback (INotificationCB *,unsigned long *)
HRESULT UnregisterCallback (unsigned long *)
HRESULT DoAction (Dummy) //Look at virtual function table for correct signature
GUID 25DEAD04-1EAC-4911-9E3A-AD0A4AB560FD
Google Chrome source with good comments:
https://chromium.googlesource.com/chrom ... ger_win.cc
https://hianz.wordpress.com/
https://gist.github.com/ysc3839/25e8ed113c4e975b6781c9759ed4ee87
https://gist.github.com/anaisbetts/e90c7d89624d1b1adc72
https://github.com/Squirrel/Squirrel.Windows/blob/master/src/Squirrel/TrayHelper.cs
https://jira.reactos.org/secure/attachment/33858/traynotify.cpp
https://titanwolf.org/Network/Articles/Article?AID=126520c2-c115-4f90-b529-5f9642912564#gsc.tab=0

Edit: https://thread0.wordpress.com/2014/11/09/workaround-windows-tray-area-item-preference/
* callback is to INotificationCB* not iTrayNotify instance?
http://www.geoffchappell.com/studies/windows/shell/explorer/interfaces/inotificationcb/index.htm?tx=30-32
EitherMouse - Multiple mice, individual settings . . . . www.EitherMouse.com . . . . forum . . . .
jadams
Posts: 58
Joined: 13 Mar 2020, 10:48

Re: Is there a way to put an icon outside the hidden tray icons by default?

28 Sep 2020, 15:36

I have a script that I desperately want this functionality for :-) there is a $100 PayPal donation to whoever can provide working code! 
gwarble
Posts: 457
Joined: 30 Sep 2013, 15:01

Re: Is there a way to put an icon outside the hidden tray icons by default?

28 Sep 2020, 16:08

I'm still trying to make sense of it, but because of the differences between the two interfaces i think we need to use iNotificationCB for the callback (somehow) with iTrayNotifyWin8
MIDL_INTERFACE("D782CCBA-AFB0-43F1-94DB-FDA3779EACCB") INotificationCB : public IUnknown

I think teadrinker got the pointers set right, and that we can ignore the new DoAction method, but I haven't quite made sense of the UnregisterCallback and the new ID and if we need to use them...

Edit: or if we need to ComObjCreate a second time with iNotificationCB? obviously I'm out of my element
EitherMouse - Multiple mice, individual settings . . . . www.EitherMouse.com . . . . forum . . . .
teadrinker
Posts: 1856
Joined: 29 Mar 2015, 09:41
Contact:

Re: Is there a way to put an icon outside the hidden tray icons by default?

29 Sep 2020, 00:02

@gwarble
Why do you think that a working solution does exist for the latest Windows version?
malcev
Posts: 708
Joined: 12 Aug 2014, 12:37

Re: Is there a way to put an icon outside the hidden tray icons by default?

29 Sep 2020, 04:44

I think it does not exist.
teadrinker, Your error check is not right.

Code: Select all

msgbox % Format("{:#x}", "") ; must be 0
Function can be called something like this:

Code: Select all

CLSID_TrayNotify := "{25DEAD04-1EAC-4911-9E3A-AD0A4AB560FD}"
IID_ITrayNotify8 := "{D133CE13-3537-48BA-93A7-AFCD5D2053B4}"
t := 1

q::
   pITrayNotify8 := ComObjCreate(CLSID_TrayNotify, IID_ITrayNotify8)
   VarSetCapacity(NOTIFYITEM, A_PtrSize*4 + 8 + 16 + A_PtrSize*8, 0)
   str := "AutoHotkey.exe"
   NumPut(&str, NOTIFYITEM)
   NumPut(A_ScriptHwnd, NOTIFYITEM, A_PtrSize*3)
   NumPut((t := !t) + 1, NOTIFYITEM, A_PtrSize*4, "UInt")
   NumPut(0x404, NOTIFYITEM, A_PtrSize*4 + 4, "UInt")
   msgbox % DllCall(NumGet(NumGet(pITrayNotify8+0) + 5*A_PtrSize), "Ptr", pITrayNotify8, "Ptr", &NOTIFYITEM, "UInt") ; SetPreference
   ObjRelease(pITrayNotify8)
Return
2147943568 = 0x80070490 = Element not found.
teadrinker
Posts: 1856
Joined: 29 Mar 2015, 09:41
Contact:

Re: Is there a way to put an icon outside the hidden tray icons by default?

29 Sep 2020, 08:31

malcev wrote:

Code: Select all

VarSetCapacity(NOTIFYITEM, A_PtrSize*4 + 8 + 16 + A_PtrSize*8, 0)

Code: Select all

typedef struct tagNOTIFYITEM
{
	PWSTR pszExeName;
	PWSTR pszTip;
	HICON hIcon;
	HWND hWnd;
	NOTIFYITEM_PREFERENCE dwPreference;
	UINT uID;
	GUID guidItem;
} NOTIFYITEM, *PNOTIFYITEM;
Why A_PtrSize*4 + 8 + 16 + A_PtrSize*8 ?
gwarble
Posts: 457
Joined: 30 Sep 2013, 15:01

Re: Is there a way to put an icon outside the hidden tray icons by default?

29 Sep 2020, 09:11

teadrinker wrote:
29 Sep 2020, 00:02
@gwarble
Why do you think that a working solution does exist for the latest Windows version?
only because of the linked examples above. I know there is a new interface for iTrayNotify as of Windows 8 that replaced the working version for Windows 7, so from the examples above I would only conclude that there is a working solution for Windows 8 and was hopeful that it would work in Windows 10. I do not currently have a Windows 8 setup to test on but I can if you think there actually is no solution on Windows 10 we could at least prove the interface working on WIndows 8. (anyone care to test in Win8?)

Edit: comment from malcev's link:
// Attention: This code DOES NOT work in Win10 Fall Creators Update or later. (2017/10/26)
Thanks for pointing that out guys, too bad, I wonder if they created a new hidden/undocumented interface
EitherMouse - Multiple mice, individual settings . . . . www.EitherMouse.com . . . . forum . . . .

Return to “Ask For Help”

Who is online

Users browsing this forum: Albireo, DanRim, DMDComposer, f1ster, Google [Bot], Gushou, kjmcneil, Lecso0522, mikeyww, mmmax, TAC109 and 47 guests