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
TheBeginner
Posts: 42
Joined: 19 Oct 2018, 12:05

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

11 Nov 2018, 04:17

Running a compiled script creates a tray icon, what I'm trying to do is put the icon outside the "hidden tray icons" area by default using AHK
Putting it outside by default, is that possible?
Sweetins
Posts: 61
Joined: 02 Jul 2017, 13:22

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

11 Nov 2018, 05:16

Sure is possible. Just drag the said script's tray icon from the system stray pop-up and put it on the task bar. The next time you run the script, the tray icon stays on the task bar and not in the system tray pop-up pane.
TheBeginner
Posts: 42
Joined: 19 Oct 2018, 12:05

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

11 Nov 2018, 07:04

Thanks for the reply, the thing is I'm looking to do it with a script, I don't want to go around the office dragging icons to the tray
I'm looking for a way to set it up to be external by default
gwarble
Posts: 389
Joined: 30 Sep 2013, 15:01

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

11 Nov 2018, 12:46

There is a way, but its largely undocumented and wouldn't be trivial to implement

google iTrayNotify

and please share the class you write for it
EitherMouse - Multiple mice, individual settings . . . . www.EitherMouse.com . . . . forum . . . .
TheBeginner
Posts: 42
Joined: 19 Oct 2018, 12:05

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

15 Nov 2018, 04:46

Thanks Gwarble, but it's over my skill level. I'm going to drop it for the time being.
gwarble
Posts: 389
Joined: 30 Sep 2013, 15:01

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

17 Nov 2018, 14:59

Yeah i unfortunately came to the same conclusion... but its on my list to attempt someday

until that time comes, or someone else writes a class for it, on my shop computers i use the registry edit to always show all icons... not elegant. I'd like that option from within EitherMouse but that will have to wait for a real iTrayNotify implementation
EitherMouse - Multiple mice, individual settings . . . . www.EitherMouse.com . . . . forum . . . .
User avatar
jeeswg
Posts: 6904
Joined: 19 Dec 2016, 01:58
Location: UK

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

03 Mar 2019, 01:34

- I have an attempt here, which isn't working. Tested on Windows 7.
- It's possible that tweaking it will make it work.
- Based on this link, it's possible that it will/won't work depending on the OS, and whether you run as admin or not.
winapi - ITrayNotify interface not working when Windows 7 process is elevated ("Class not registered") - Stack Overflow
https://stackoverflow.com/questions/36824485/itraynotify-interface-not-working-when-windows-7-process-is-elevated-class-not

Code: Select all

;see ITaskbarList example here:
;DllCall() - Syntax & Usage | AutoHotkey
;https://autohotkey.com/docs/commands/DllCall.htm

;NOTIFYITEM
;https://www.geoffchappell.com/studies/windows/shell/explorer/interfaces/notifyitem.htm
;typedef struct tagNOTIFYITEM {
;    PWSTR pszExeName;
;    PWSTR pszTip;
;    HICON hIcon;
;    HWND hWnd;
;    DWORD dwPreference;
;    UINT uID;
;    GUID guidItem;
;} NOTIFYITEM;

;NOTIFYITEM
;https://www.geoffchappell.com/studies/windows/shell/explorer/interfaces/notifyitem.htm
;0x00 hide when inactive
;0x01 always hide
;0x02 always show

q:: ;test ITrayNotify SetPreference
CLSID_TrayNotify := "{25DEAD04-1EAC-4911-9E3A-AD0A4AB560FD}"
IID_ITrayNotify := "{FB852B2C-6BAD-4605-9551-F15F87830935}"
pTN := ComObjCreate(CLSID_TrayNotify, IID_ITrayNotify)
vPath := A_AhkPath
VarSetCapacity(NOTIFYITEM, A_PtrSize=8?56:40, 0)
NumPut(&vPath, &NOTIFYITEM, 0, "Ptr") ;pszExeName
NumPut(2, &NOTIFYITEM, A_PtrSize=8?32:16, "UInt") ;dwPreference
DllCall(NumGet(NumGet(pTN+0)+4*A_PtrSize), Ptr,pTN, Ptr,&NOTIFYITEM) ;SetPreference
ObjRelease(pTN)
return
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
teadrinker
Posts: 1064
Joined: 29 Mar 2015, 09:41
Contact:

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

03 Mar 2019, 16:10

On Windows 7 it works like this:

Code: Select all

;see ITaskbarList example here:
;DllCall() - Syntax & Usage | AutoHotkey
;https://autohotkey.com/docs/commands/DllCall.htm

;NOTIFYITEM
;https://www.geoffchappell.com/studies/windows/shell/explorer/interfaces/notifyitem.htm
;typedef struct tagNOTIFYITEM {
;    PWSTR pszExeName;
;    PWSTR pszTip;
;    HICON hIcon;
;    HWND hWnd;
;    DWORD dwPreference;
;    UINT uID;
;    GUID guidItem;
;} NOTIFYITEM;

;NOTIFYITEM
;https://www.geoffchappell.com/studies/windows/shell/explorer/interfaces/notifyitem.htm
;0x00 hide when inactive
;0x01 always hide
;0x02 always show

t := 1
q:: ;test ITrayNotify SetPreference
CLSID_TrayNotify := "{25DEAD04-1EAC-4911-9E3A-AD0A4AB560FD}"
IID_ITrayNotify := "{FB852B2C-6BAD-4605-9551-F15F87830935}"
pTN := ComObjCreate(CLSID_TrayNotify, IID_ITrayNotify)

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

NumPut((t := !t) + 1, NOTIFYITEM, A_PtrSize*4, "UInt") ;dwPreference

NumPut(0x404, NOTIFYITEM, A_PtrSize*4 + 4, "UInt")
DllCall(NumGet(NumGet(pTN+0)+4*A_PtrSize), Ptr,pTN, Ptr,&NOTIFYITEM) ;SetPreference
ObjRelease(pTN)
return
On Windows 10 this code produces the error "Interface is not supported".
User avatar
jeeswg
Posts: 6904
Joined: 19 Dec 2016, 01:58
Location: UK

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

03 Mar 2019, 16:42

- Cheers teadrinker, here's a fixed version of my script above. It worked in Windows 7, when the script was non-admin. [EDIT: It failed on Windows 7, when the script was admin, reporting '0x80040154 - Class not registered'.]
- What's changed is that I've added hWnd and uID to NOTIFYITEM, but removed pszExeName.

Code: Select all

vToggle := 0

q:: ;test ITrayNotify SetPreference
vToggle := !vToggle
CLSID_TrayNotify := "{25DEAD04-1EAC-4911-9E3A-AD0A4AB560FD}"
IID_ITrayNotify := "{FB852B2C-6BAD-4605-9551-F15F87830935}"
pTN := ComObjCreate(CLSID_TrayNotify, IID_ITrayNotify)
VarSetCapacity(NOTIFYITEM, A_PtrSize=8?56:40, 0)
NumPut(A_ScriptHwnd, &NOTIFYITEM, A_PtrSize=8?24:12, "Ptr") ;hWnd
NumPut(vToggle+1, &NOTIFYITEM, A_PtrSize=8?32:16, "UInt") ;dwPreference
NumPut(0x404, &NOTIFYITEM, A_PtrSize=8?36:20, "UInt") ;uID
DllCall(NumGet(NumGet(pTN+0)+4*A_PtrSize), Ptr,pTN, Ptr,&NOTIFYITEM) ;SetPreference
ObjRelease(pTN)
return
- To get tray icon info (e.g. hWnd, uID), see my oTrayInfo example, here:
GUIs via DllCall: text functions (get/set internal/external control text) - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=6&t=40514
- Or use this script:
[LIB] TrayIcon - Sean's TrayIcon for Unicode and 64 bit - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=6&t=1229
Last edited by jeeswg on 03 Mar 2019, 17:15, edited 1 time 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
User avatar
jeeswg
Posts: 6904
Joined: 19 Dec 2016, 01:58
Location: UK

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

03 Mar 2019, 17:09

- Some links:
ITrayNotify
https://www.geoffchappell.com/studies/windows/shell/explorer/interfaces/itraynotify/index.htm
NOTIFYITEM
https://www.geoffchappell.com/studies/windows/shell/explorer/interfaces/notifyitem.htm
winapi - ITrayNotify interface not working when Windows 7 process is elevated ("Class not registered") - Stack Overflow
https://stackoverflow.com/questions/36824485/itraynotify-interface-not-working-when-windows-7-process-is-elevated-class-not
Undocumented API ITrayNotify. · GitHub
https://gist.github.com/ysc3839/25e8ed113c4e975b6781c9759ed4ee87
TrayNotify C# (CSharp) Code Examples - HotExamples
https://csharp.hotexamples.com/examples/-/TrayNotify/-/php-traynotify-class-examples.html

- @teadrinker: Did you find a good source saying which parameters were needed for NOTIFYITEM?
- I was going to reread through the links above, but hadn't had the chance yet.
- And btw, there might be some code in one of the links that will make it work on Windows 10, e.g. I saw a reference to ITrayNotifyWin8. Cheers.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
teadrinker
Posts: 1064
Joined: 29 Mar 2015, 09:41
Contact:

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

03 Mar 2019, 17:27

jeeswg wrote: - @teadrinker: Did you find a good source saying which parameters were needed for NOTIFYITEM?
I used Shell_NotifyIcon with NOTIFYICONDATA before, it's a bit similar.
jeeswg wrote: there might be some code in one of the links that will make it work on Windows 10, e.g. I saw a reference to ITrayNotifyWin8.
Tried ITrayNotifyWin8, this interface does nothing on my Windows 10.
User avatar
jeeswg
Posts: 6904
Joined: 19 Dec 2016, 01:58
Location: UK

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

03 Apr 2019, 14:30

- Since it can make a difference whether a script is run as admin or not.
- E.g. on Windows 7 it, counterintuitively, *fails* when run as admin, but *succeeds* when run as non-admin.
- Here is a way to launch an admin script from a non-admin script, and a non-admin script from an admin script.
Reloading: Admin to Non-Admin - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=5&t=7752
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
gwarble
Posts: 389
Joined: 30 Sep 2013, 15:01

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

18 Apr 2019, 11:49

jeeswg & teadrinker: many thanks! now to understand it and test it
EitherMouse - Multiple mice, individual settings . . . . www.EitherMouse.com . . . . forum . . . .

Return to “Ask For Help”

Who is online

Users browsing this forum: Bing [Bot], TAC109, tallguyyo and 221 guests